I am trying to make a holding animation for my gun. It appears for the player and for the server, but odly enough. Not the other clients. Here is my code if you want to see it:
local tool = script.Parent
local IsReloading = false
local animplay – makes it nil and u can call it in more functions
tool.Equipped:Connect(function()
local humanoid = script.Parent.Parent:WaitForChild(“Humanoid”, 5)
local animation = script.Parent.ToolEquipAnim
animplay = humanoid:LoadAnimation(animation)
animplay.Priority = Enum.AnimationPriority.Idle
animplay:Play() – idle animations should be looped
I am confused why this isn’t working too. However I see 2 reasons why.
Reason 1
The main one is when you call the humanoid you’re using :WaitForChild() what could happen is that by the time it gets the object the objects properties may have changed, giving an unexpected result. Simply try and call the humanoid with the method :FindFirstChild() or simply use no method to call it.
Reason 2
A more rarely one I could see is that since you’re setting the animation priority to Idle it may not have a high enough priority to play. To fix this we need to change it from Idle to Enum.AnimationPriority.Action
Hmm, possibly you are overriding the animation. Try doing ctrl + f and typing “Anim”. If you can’t find anything try and read your code to yourself as this is obviously a “logic error” now.
Your script works fine for me. Maybe it’s your animation priority that you chose when you exported it. Re-export it, and for the animation priority choose action instead of core
here is the code i have now. It doesnt seem to work still local tool = script.Parent
local IsReloading = false
local animplay – makes it nil and u can call it in more functions
tool.Equipped:Connect(function()
local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local animation = script.Parent.ToolEquipAnim
animplay = humanoid:LoadAnimation(animation)
animplay.Priority = Enum.AnimationPriority.Action
animplay:Play() – idle animations should be looped
end)
tool.Unequipped:Connect(function()
if animplay ~= nil then – if its not blank or nil
animplay:Stop()
end
end)
while wait(.1) do
if script.Parent.Parent.Parent == workspace then
animplay:Play()
end
end
Ahhh, I see. So, I guess setting the animation priority via script only works locally. I know I already said this, but make sure you open up your animation editor again, import the one you are working with, go to set animation priority, choose action, export it, and then get the new animation ID. That is what fixed it for me.