Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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.

0
Should be a simple fix. Just change the 'LoadAnimation:Stopped()' to 'LoadAnimation:Stop()' It should fix the problem XviperIink 428 — 5y
0
But when I did that then the Animation doesn't play at all rochel89 42 — 5y
0
Thank you all! rochel89 42 — 5y

1 answer

Log in to vote
0
Answered by
BenSBk 781 Moderation Voter
5 years ago

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)
0
Does this thing have the same use for Play()? rochel89 42 — 5y
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. BenSBk 781 — 5y
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 rochel89 42 — 5y
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. BenSBk 781 — 5y
View all comments (3 more)
0
Ok rochel89 42 — 5y
0
The thing is when the animation plays it doesn't stop you from jumping rochel89 42 — 5y
0
Again, you need to assign the JumpPower to 0 when you play the animation. BenSBk 781 — 5y
Ad

Answer this question