CDuckdk

Checkpoint Script

Feb 9th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. local spawn = script.Parent
  2. spawn.Touched:connect(function(hit)
  3. if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
  4. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  5. local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
  6. if not checkpointData then
  7. checkpointData = Instance.new("Model", game.ServerStorage)
  8. checkpointData.Name = "CheckpointData"
  9. 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.  
  16. player.CharacterAdded:connect(function(character)
  17. wait()
  18. character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
  19. end)
  20. end
  21.  
  22. checkpoint.Value = spawn
  23. end
  24. end)
Add Comment
Please, Sign In to add comment