Advertisement
Jonny_Zuko_onYoutube

roblox checkpoint

Dec 13th, 2019
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. -- this is a checkpoint script and may be used in obby's
  2.  
  3. function on(hit)
  4. if hit.Parent ~= nil then
  5. local player = game.Players:playerFromCharacter(hit.Parent)
  6. if player ~= nil then
  7. if player.leaderstats.Stage.Value == script.Parent.Name - 1 then
  8. local h = hit.Parent:FindFirstChild("Humanoid")
  9. if h ~= nil then
  10. if h.Health ~= 0 then
  11. player.leaderstats.Stage.Value = script.Parent.Name
  12. end end end end end end
  13.  
  14. script.Parent.Touched:connect(ot)
  15. local spawn = script.Parent
  16. spawn.Touched:connect(function(hit)
  17. if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
  18. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  19. local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
  20. if not checkpointData then
  21. checkpointData = Instance.new("Model", game.ServerStorage)
  22. checkpointData.Name = "CheckpointData"
  23. end
  24.  
  25. local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
  26. if not checkpoint then
  27. checkpoint = Instance.new("ObjectValue", checkpointData)
  28. checkpoint.Name = tostring(player.userId)
  29.  
  30. player.CharacterAdded:connect(function(character)
  31. wait()
  32. character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
  33. end)
  34. end
  35.  
  36. checkpoint.Value = spawn
  37. end
  38. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement