Now let me get this straight - although the title says fall damage, I am not actually looking for something that will damage the player. What I am asking is how I can create a system similar to fall damage that will play an animation when the player hits the ground after a long fall. Say you jump off a 10 foot wall in real life. You would obviously collapse to your knees or have some reaction, and I’m positive you would not keep running like nothing just happened.
local t = nil
local falltime = nil
local humanoid = game.Players.LocalPlayer.Character.Humanoid
humanoid.StateChanged:Connect(function(oldstate , newstate)
if newstate == "Freefall" then
t = tick()
else if newstate == "Landed" and t then
falltime = tick() - t
end
end)
Because my pc is not available to me right now I am not really able to test if this really works but you can try it out if you get it.
Thanks for the reply. This is my current Local Script located in StarterCharacterScripts. It does not seem to be working, do you know what I am doing wrong?
local t = nil
local falltime = nil
local humanoid = game.Players.LocalPlayer.Character.Humanoid
local anim = Instance.new(‘Animation’)
anim.AnimationId = ‘rbxassetid://7286026184’
local loaded = humanoid:LoadAnimation(anim)
humanoid.StateChanged:Connect(function(oldstate , newstate)
if newstate == “Freefall” then
t = tick()
else if newstate == “Landed” and t then
falltime = tick() - t
loaded:Play()
end
end
end)