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

Trouble with playing an animation from a tool?

I have a local script inside a tool. In the same hierarchy level is the handle and animation. For some reason the animation won't play when the tool is used. I tested this exact code from a local script in the StarterGui, but with uis, and it worked just fine. The animation prints Play, then Stop, but does nothing. No errors. Any help is greatly appreciated.

script.Parent.Activated:Connect(function()
	local animation = script.Parent.Eat
    local track =  game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(animation)
	print('Start')
    track:Play()
	wait(1)
	track:Stop()
	print('Stop')
end)

3 comments

0

The priority may be lower than the Default tool holding animación maybe¿

0

probably, know a way to fix it...

0

Says the priority is Action, highest, though

1 answer

✓ Accepted answer

I think the problem is that you don't have a "Handle" in your tool


local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local humanoid = char.Humanoid

--[[
local handle = Instance.new("Part")
handle.Parent = tool
handle.Name = "Handle"
]]


local tool = script.Parent
local EatAnimation = tool.Eat

local p = humanoid:LoadAnimation(EatAnimation)
p.Priority = Enum.AnimationPriority.Action

tool.Activated:Connect(function()
	p:Play()
	wait(1)
	p:Stop()
end)

3 comments

0

It works now. Thanks

0

realy?

0

Yeah, I reorganized your script a bit, but your code made it work

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