I’m making fall damage for my game currently, and it doesn’t work. It only prints ‘Falling’, I’m not good at making things related to the humanoid. I know what to do, but don’t know how to make it work. Here’s my attempt.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Velocity
local humanoid = char:WaitForChild("Humanoid")
local falling = false
humanoid.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Freefall or Enum.HumanoidStateType.FallingDown then
Velocity = char.Torso.Velocity.Y
print("Falling")
end
humanoid.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Freefall then
falling = true
while falling do
wait(.05)
Velocity = char.HumanoidRootPart.Velocity.Y
end
elseif Enum.HumanoidStateType.Landed then
if Velocity >-20 then
falling = false
elseif Velocity <-20 then
humanoid:TakeDamage(Velocity)
Velocity = 0
falling = false
end
end
end)
end)
end)
end)