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

Looped Animation still plays after using :Stop(), how do I fix this?

Asked by
TtuNkK 37
4 years ago
game.ReplicatedStorage.FruitRemotes.GomuGomu.Pistol.OnServerEvent:Connect(function(player, hit, fruit)
    local pistolAnim = character:WaitForChild("Humanoid"):LoadAnimation(game.ReplicatedStorage.Animations.GomuGomu.PistolAnim)
    pistolAnim:Play()

end)

game.ReplicatedStorage.FruitRemotes.GomuGomu.PistolAttack.OnServerEvent:Connect(function(player, hit, fruit)
    local oldAnimation = character.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.GomuGomu.PistolAnim)
    oldAnimation:Stop()

end)

The code used to work, but now it doesn't. Could it possibly be a bug?

0
hmm ill look into it bigkiddo27 6 — 4y
0
Thanks! TtuNkK 37 — 4y
0
It most likely only works once, try adding a loop to stop the music more than once.. JesseSong 3916 — 4y
View all comments (4 more)
0
I'm using Animations, but I'll give that a try TtuNkK 37 — 4y
0
Didn't work. I even checked if it printed, and it did. This is sooo weird... TtuNkK 37 — 4y
0
When you stop an animation, it will continue until it's animation track is over. Worthfall 2 — 4y
0
Well it worked last time, now it all of a sudden doesn't. TtuNkK 37 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

I am not an expert, but you could try first to set the Looped animation to false and then to stop. This could might work. Else you could try to check if the Remote Event/Function get even fired. Check it with

game.ReplicatedStorage.FruitRemotes.GomuGomu.Pistol.OnServerEvent:Connect(function(player, hit, fruit)
    local pistolAnim = character:WaitForChild("Humanoid"):LoadAnimation(game.ReplicatedStorage.Animations.GomuGomu.PistolAnim)
    pistolAnim:Play()

end)

game.ReplicatedStorage.FruitRemotes.GomuGomu.PistolAttack.OnServerEvent:Connect(function(player, hit, fruit)
    local oldAnimation = character.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.GomuGomu.PistolAnim)
    print("TEST")
    oldAnimation:Stop()

end)

I Hope I could helped you a bit infront :-)

0
The remote events do work, but the :Stop() doesn't work as if it was never there. I tried setting the Looped to false, but it only worked for specific areas TtuNkK 37 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Its because you are loading the animation again. you can fix it by making the animation variable a global variable.

game.ReplicatedStorage.FruitRemotes.GomuGomu.Pistol.OnServerEvent:Connect(function(player, hit, fruit)
pistolAnim =character:WaitForChild("Humanoid"):LoadAnimation(game.ReplicatedStorage.Animations.GomuGomu.PistolAnim)
    pistolAnim:Play()

end)

game.ReplicatedStorage.FruitRemotes.GomuGomu.PistolAttack.OnServerEvent:Connect(function(player, hit, fruit)
    pistolAnim:Stop()

end)

Answer this question