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

Greetings all! Can Someone help with a script regarding animations in tools?

Thanks for reading this, and i will give an example of the script, but I need some help with a script about animations. (specifically when you hold the tool and it plays an animation, aka - Tool Idle animation) When i hold the tool, it does play the animation, so it would seem fine, right? Wrong, the animation only plays for the holder, aka it would seem the animation is client-sided only, and this is the problem im having.

The Script:

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=5209981398"
local track
tool.Equipped:Connect(function()
    track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
    track.Priority = Enum.AnimationPriority.Action
    track.Looped = true
    track:Play()
end)
tool.Unequipped:Connect(function()
    if track then
        track:Stop()
    end
end)

Can i please get some help from one of you wonderful scripters out there! :)

I would greatly appreciate it and take care in these lockdown times..

3 comments

0

Just a note - The animation does play but only the holder of the tool can see it, and i need everyone in the server to see the animation

0

https://imgur.com/a/B89cRNo what im trying to do

0

2 answers

Try to set the priority / looped in the animation editor instead of it being scripted, and also make sure none of the baseparts are anchored

Put an global script on starter character scripts and put like this

script.Parent.ChildAdded:Connect(function(Child)
      if Child.ClassName == "Tool" then
if Child:FindFirstChildOfClass("Animation") then
local animation = script.Parent.Humanoid:LoadAnimation(Child:FindFirstChildOfClass("Animation"))
animation:Play()
script.Parent.ChildRemoved:Connect(function(child)
if child == Child then
animation:Stop()
end)
end
end
end)

Hope it works!

2 comments

0

When you put my script, Dont forget to put an animation object inside the tool and put the animationid in loop and the animation type needs to be Action! So it would work

0

Thank you! It worked.. thanks for helping and i really appreciate it! Take care and yet again thank you

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