I'm making an obby so I put a few spawn points for checkpoints. but everytime I die it just sends me to a random checkpoint and not the one right before I died, how do I fix this?
Make sure neutral is disaled and AllowTeamChangeOnTouch is enabled. Also try making a different team color for each checkpoint.
Insert a normal Script in each of the parts and add the code to make the player return where they left off after they died.
01 | local spawn = script.Parent -- Find where the part is |
02 | spawn.Touched:connect( function (hit) -- When the player touches the part |
03 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then -- If the player who touches the part is a humanoid |
04 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Find any players |
05 | local checkpointData = game.ServerStorage:FindFirstChild( "CheckpointData" ) -- Creates some sort of Data Store |
06 | if not checkpointData then |
07 | checkpointData = Instance.new( "Model" , game.ServerStorage) |
08 | checkpointData.Name = "CheckpointData" |
09 | end |
10 |
11 | local checkpoint = checkpointData:FindFirstChild( tostring (player.userId)) |
12 | if not checkpoint then |
13 | checkpoint = Instance.new( "ObjectValue" , checkpointData) |
14 | checkpoint.Name = tostring (player.userId) |
15 |