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

Trouble with playing an animation from a tool?

Asked by
sheepposu 561 Moderation Voter
5 years ago

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)
0
The priority may be lower than the Default tool holding animación maybe¿ User#24403 69 — 5y
0
probably, know a way to fix it... sheepposu 561 — 5y
0
Says the priority is Action, highest, though sheepposu 561 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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)
0
It works now. Thanks sheepposu 561 — 5y
0
realy? asdfghjk9019 225 — 5y
0
Yeah, I reorganized your script a bit, but your code made it work sheepposu 561 — 5y
Ad

Answer this question