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

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

Asked by 4 years ago
Edited 4 years ago

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..

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 ParSoft 2 — 4y
0
https://imgur.com/a/B89cRNo what im trying to do ParSoft 2 — 4y
0
https://imgur.com/a/pe5iIAC the problem ParSoft 2 — 4y

2 answers

Log in to vote
0
Answered by
Omzure 94
4 years ago
Edited 4 years ago

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

Ad
Log in to vote
0
Answered by 4 years ago

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!

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 shadow2008_br 176 — 4y
0
Thank you! It worked.. thanks for helping and i really appreciate it! Take care and yet again thank you ParSoft 2 — 4y

Answer this question