Currently working on a function to make a player perform a long-jump similar to Super Mario 64. The function first checks if the player is airborne by checking if the Humanoid’s FloorMaterial is air. Next, it begins a looping animation that will continue until the player lands again. This is where my issue is.
The way I have this set up is I have a separate function to check when a player hits the ground, and if they’re currently performing a long-jump, it will be stopped.
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
if Humanoid.FloorMaterial ~= Enum.Material.Air and islongJumping == true then
islongJumping = false
Humanoid.WalkSpeed = 20
longJumpTrack:Stop()
end
end)
This works most of the time, but it completely breaks if a player performs a long-jump, and lands before the Humanoid’s FloorMaterial can update (usually happens if a player long-jumps into a wall). I know this method is barbaric, but I genuinely can’t think of another way to detect a player landing from such a small height.
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
if islongJumping and Humanoid.FloorMaterial ~= Enum.Material.Air then
islongJumping = false
Humanoid.WalkSpeed = 20
if longJumpTrack and longJumpTrack:IsPlaying() then
longJumpTrack:Stop()
end
end
end)
Try this it should work, it tracks when the player is jumping,etc it should help it
My issue wasn’t that the animation didn’t stop, it was that the function itself doesn’t get called sometimes due to the FloorMaterial never updating (usually because the jump was small/was interrupted)
I’m looking for an alternative that doesn’t check for FloorMaterial
You can’t write to GetState. I’m assuming you meant ChangeState? Even then, that would just make the character jump again.
Anyway, I fixed it by forcing the Humanoid to enter FreeFall upon performing a long-jump, then listening for a state change to Landed to end the animation. This works consistently regardless of how quickly the long-jump is cancelled.
Ah, I see what you mean. That’s basically what I ended up doing
(current script if anyone is curious)
Humanoid.StateChanged:Connect(function()
if Humanoid:GetState() == Enum.HumanoidStateType.Landed and islongJumping == true then
islongJumping = false
Humanoid.WalkSpeed = 20
longJumpTrack:Stop()
end
end)