Advertisement
Yondiux

daño por caida script (SERVERSCRIPTSERVICE))

Apr 23rd, 2021
6,681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. game.Players.PlayerAdded:Connect(function(plr)
  2.  
  3.  
  4. plr.CharacterAdded:Connect(function(char)
  5.  
  6.  
  7. local startPos
  8.  
  9.  
  10. local humanoid = char:WaitForChild("Humanoid")
  11.  
  12.  
  13. humanoid.StateChanged:Connect(function(oldState, newState)
  14.  
  15.  
  16. if newState == Enum.HumanoidStateType.Freefall then
  17.  
  18. startPos = char:WaitForChild("HumanoidRootPart").Position.Y
  19.  
  20.  
  21. elseif newState == Enum.HumanoidStateType.Landed then
  22.  
  23.  
  24. if not startPos then return end
  25.  
  26.  
  27. local landPos = char:WaitForChild("HumanoidRootPart").Position.Y
  28.  
  29.  
  30. if startPos < landPos then return end
  31.  
  32.  
  33. local distanceFallen = (startPos - landPos)
  34.  
  35.  
  36. humanoid:TakeDamage(distanceFallen)
  37. end
  38. end)
  39. end)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement