Jump to content

[sloved] my player dies when i try to send him back to a area


bl4cknite
 Share

Recommended Posts

Script.respawnPoint = "" -- entity "Resspawn point"

function Script:Collision (entity, position, normal, speed)
if (entity:GetKeyValue ("name") == "Player") then
spawnpos = self.respawnPoint:GetPosition()
entity:SetPosition(spawnpos)
spawnRot = self.respawnPoint:GetRotation()
entity.script.camRotation = spawnRot

end
end

hi i was trying to have it when the player hits a place it brings them back to the area before.

i had it working but nor it kills the player sometimes when he hits the trigger.

 

 

 

Thanks in advance.

Link to comment
Share on other sites

The only thing I can see wrong with it is that you have local variables that haven't been created with the "local" keyword.

 

Script.respawnPoint = "" -- entity "Resspawn point"
function Script:Collision (entity, position, normal, speed)
  if (entity:GetKeyValue ("name") == "Player") then
    local spawnpos = self.respawnPoint:GetPosition()
    entity:SetPosition(spawnpos)
    local spawnRot = self.respawnPoint:GetRotation()
    entity.script.camRotation = spawnRot
  end 
end

Link to comment
Share on other sites

I wouldn't make a trigger respawn the player like this. It'd be better if you'd intergrate the respawn code in the player script. Then call the player's respawn function with the trigger or when the player's health reaches 0.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...