Animation plays on server but not other clients

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

end)

tool.Unequipped:Connect(function()

if animplay ~= nil then – if its not blank or nil

animplay:Stop()

end

end)

1 Like

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

1 Like

I originally had it at movement. Thank you im going to try them now!

1 Like

i did it here are the results image

hehe not what you were expecting

server:
image

Another thing I can see is that you are not replicating it to the client. Are you calling this on the server?

tbh to prevent this very issue i have both client and server scripts that do the same thing. Wait is that the problem ;-;

Assuming this is a tool, animations get replicated to the server and all clients if you do it on a local script

well now it works… for about 1 second image

image

i deleted the server script btw

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.

I tried the overriding thing it didnt work ;-; yeah nothing at all works

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

Ok thank you. Ima try doing what you said

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

Im going to try to restart roblox studio

Still isnt working 30 charssssws

It must be some other script that is overriding it. This is how it functions for me.

But try doing a 2 player test…

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

1 Like

OMG THANK YOU SOO MUCH!!! it works

image

1 Like