Advertisement
szze

Untitled

Apr 10th, 2023
6,639
-2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 2
  1. local players = game:GetService('Players')
  2. local lplr = players.LocalPlayer
  3. local lastCF, stop, heartbeatConnection
  4. local function start()
  5. heartbeatConnection = game:GetService('RunService').Heartbeat:Connect(function()
  6. if stop then
  7. return
  8. end
  9. lastCF = lplr.Character:FindFirstChildOfClass('Humanoid').RootPart.CFrame
  10. end)
  11. lplr.Character:FindFirstChildOfClass('Humanoid').RootPart:GetPropertyChangedSignal('CFrame'):Connect(function()
  12. stop = true
  13. lplr.Character:FindFirstChildOfClass('Humanoid').RootPart.CFrame = lastCF
  14. game:GetService('RunService').Heartbeat:Wait()
  15. stop = false
  16. end)
  17. lplr.Character:FindFirstChildOfClass('Humanoid').Died:Connect(function()
  18. heartbeatConnection:Disconnect()
  19. end)
  20. end
  21.  
  22. lplr.CharacterAdded:Connect(function(character)
  23. repeat
  24. game:GetService('RunService').Heartbeat:Wait()
  25. until character:FindFirstChildOfClass('Humanoid')
  26. repeat
  27. game:GetService('RunService').Heartbeat:Wait()
  28. until character:FindFirstChildOfClass('Humanoid').RootPart
  29. start()
  30. end)
  31.  
  32. lplr.CharacterRemoving:Connect(function()
  33. heartbeatConnection:Disconnect()
  34. end)
  35.  
  36. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement