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

animation stopping after player moves??

there's tool that plays an animation but when the player moves the animation stops
this is a local script inside of a tool

enabled = false
local Tool = script.Parent;
local dancer = nil



function onActivated()




if enabled == false then
	local humanoid = Tool.Parent:FindFirstChild("Humanoid")

	dancer = humanoid:LoadAnimation(Tool.dance)
	Tool.DanceObject.Value = dancer
	dancer:Play()
	enabled = true
	
	repeat 
	wait(1)
	until enabled == false

else
	dancer:Stop()
	dancer:remove()
	enabled = false
end
end

function onUnequipped()
		dancer:Stop()
		dancer:remove()
		enabled = false
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)

help

1 answer

✓ Accepted answer

Just change the animation priority to action

enabled = false
local Tool = script.Parent;
local dancer = nil



function onActivated()




if enabled == false then
    local humanoid = Tool.Parent:FindFirstChild("Humanoid")

    dancer = humanoid:LoadAnimation(Tool.dance)
    dancer.Priority = Enum.AnimationPriority.Action
    Tool.DanceObject.Value = dancer
    dancer:Play()
    enabled = true

    repeat 
    wait(1)
    until enabled == false

else
    dancer:Stop()
    dancer:remove()
    enabled = false
end
end

function onUnequipped()
        dancer:Stop()
        dancer:remove()
        enabled = false
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)

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