What do you want to achieve? I want to know why this is not working and how i can fix it
What is the issue? The animation wont stop playing, i have already used :Stop() but it doesnt work
What solutions have you tried so far? I have been trying with variables and stuff but nothing is working
This is currently in a normal script, i have also tried a local script:
local char = script.Parent.Parent
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local holdAnim = animator:LoadAnimation(script.Animation)
local holding = false
script.Parent.Equipped:Connect(function()
holding = true
if holding == true then
holdAnim:Play()
end
end)
script.Parent.Unequipped:Connect(function()
holding = false
holdAnim:Stop()
end)
If you want the animation to keep playing, it’s best to make the animation loop, then just play it and stop it whenever you need to. You should put this in a localscript. Try this:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local holdAnim = animator:LoadAnimation(script.Animation)
holdAnim.Looped = true
script.Parent.Equipped:Connect(function()
holdAnim:Play()
end)
script.Parent.Unequipped:Connect(function()
holdAnim:Stop()
end)