So I’m working on an obby with basic checkpoints where the player is supposed to spawn after death, but sometimes it looks like it’s trying to spawn on the original spawn, like in the video I recorded.
And I’m not really sure why it would do this, sometimes it does it even faster so you might not even realise it - could it be because of internet issues lol?
on checkpoint touch I have this code:
player.CharacterAdded:connect(function(character)
wait()
if game.ServerStorage.CheckpointData[tostring(player.userId)].Value then
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end
end)
What could be the problem? Might it be because I have other player.CharacterAdded functions in other scripts?
I think its because: first your character has to load, then it waits for a moment, and finally script sets a new CFrame for your character. Also wait can take longer time than expected, so it takes a while until it teleports player. I think you can reduce the time taken to set new CFrame using this:
player.CharacterAdded:connect(function(character)
local charwait = character:WaitForChild("HumanoidRootPart")
if game.ServerStorage.CheckpointData[tostring(player.userId)].Value then
charwait.CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end
end)
removing wait() makes the character load at spawn at all times unfortunately
I tried keeping the wait() and waiting for HumanoidRootPart but it still acts the same