Simple line not working

Hello,

Down below is my script I am writing that plays an animation and waits for it to end then makes a script enabled.

script.Parent.ToolClicked.OnServerEvent:Connect(function(plr)
script.Parent.Ended.Value = false
local animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 40
plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value + 25
wait(1.7)
animation:Stop()
wait(1)
script.Parent.LocalScript.Disabled = false --Line that is not working
script.Parent.Ended.Value = true
end)

When I run the game the script does not get unDisabled. I enabled it with the command line on studio and that worked.
Also, is there a better way to know when an animation ended.
Thanks for your help.

I’d recommend you run the animations on the client directly. Run all your code that handles running and waiting for the animations, then call an event to the server to update the player’s coins and strength. Animation replication should be automatic in this scenario, so don’t worry about that.

1 Like