Hey guys! So, my friend is helping me learn scripting. And I've also been following the wiki.
I have made this script with the help of the wiki and my friend, and he told me to figure it out for myself.
So, I wanted to make a script so you can re spawn when you die. I did it and it was quite easy, but you re spawned straight away. I asked my friend if I could use a timer or something so you have to wait for 5 seconds until you re spawn. Here is what I came up with so far:
local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125
function joinHandler()
spawnPlayer(source, spawnX, spawnY, spawnZ)
fadeCamera(source, true)
setCameraTarget(source, source)
outputChatBox("Welcome to the test server!", source)
end
addEventHandler("onPlayerJoin", getRootElement(), joinHandler)
function deathTimer()
setTimer(deathHandler,5000,1)
end
local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125
function deathHandler()
spawnPlayer(source, spawnX, spawnY, spawnZ)
fadeCamera(source, true)
setCameraTarget(source, source)
outputChatBox("And... BAM, you're back!", source)
end
addEventHandler("onPlayerWasted", getRootElement(), deathTimer)
The problem is with this, the timer works and it waits for 5 seconds, but in staid of respawning, only the text shows and your camera is left floating in the sky. I made a video for it here: https://www.youtube.com/watch?v=sxzJVwTWHCo&feature=youtu.be
Any help with this would me much appreciated!
Thanks
Tiger.