Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

There's an error on line 4.Am I doing this correctly?

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.

4 comments

0

Should be a simple fix. Just change the 'LoadAnimation:Stopped()' to 'LoadAnimation:Stop()' It should fix the problem

0

But when I did that then the Animation doesn't play at all

0

Thank you all!

1 answer

✓ Accepted answer

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)

7 comments

0

Does this thing have the same use for Play()?

0

As far as I'm aware, there is no event that fires when an animation starts playing. You can instead just run the code when you play the animation.

0

Cause it seem that the first line of code from mines It's supposed to make you stop jumping to prevent ending the animation but it doesn't seem to go in plan

0

When you play the animation, why not just assign the JumpPower to 0? The event will take care of assigning it back to 50.

0

Ok

0

The thing is when the animation plays it doesn't stop you from jumping

0

Again, you need to assign the JumpPower to 0 when you play the animation.

This discussion is preserved as it was. New answers, comments, and votes are closed.