What I'm trying to do is when the Animation Track stopped playing,I wanted the jump power of the player to return to normal.But there is an error on line 4,Is there anything wrong??
if LoadAnimation:Play() then Char.Humanoid.JumpPower = 0 end if LoadAnimation:Stopped() then Char.Humanoid.JumpPower = 50 end
I already did the rest of the code but this is just a summarized version.
In your snippet of code, you attempt to call LoadAnimation:Stopped()
. There is no Stopped function in the Roblox API, which is why you receive the error.
Instead, it looks like you're looking for an RBXScriptSignal, also known as an event. These are objects that are fired whenever something takes place. When an event is fired, it calls any functions connected to it. You may have seen events before in situations such as this:
game:GetService("Players").PlayerAdded:Connect(function(player) -- connect an anonymous function that prints the player's Name to the Players.PlayerAdded event print(player.Name) end)
In your case, you want something to happen when an animation stops. We can use the event AnimationTrack.Stopped
, which you can learn more about here, for this. It would look something like this:
LoadAnimation.Stopped:Connect(function() Char.Humanoid.JumpPower = 50 end)