Hey there! I’m trying to make a hold script for a tool, but it’s only playing the animation to the client, not the server. I’m using a local script for this hold animation… I heard that with a local script, it will replicate the animation to the server so I don’t know what’s the issue here. I’ve tried using a server script for creating the instance and I’ve tried using a running the animation on it as well with no luck. Any solutions?
Code:
local tool = script.Parent
local equipAnim = Instance.new("Animation")
equipAnim.AnimationId = "rbxassetid://5673888071"
tool.Equipped:Connect(function()
local equipTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(equipAnim)
equipTrack.Priority = Enum.AnimationPriority.Action
equipTrack.Looped = true
equipTrack:Play()
end)
A local script will only play on your client. things like killing a character deleting, adding, or doing most anything or a local script will not work on the server. If you want to play an animation on the server side then I suppose you use a remote events.
here is what you should do:
--place a local script for when your character is holding the tool:
local tool = script.Parent
local equipAnim = Instance.new("Animation")
equipAnim.AnimationId = "rbxassetid://5673888071"
tool.Equipped:Connect(function()
--now instead add a remote event into game.ReplicatedStorage and name it playAnim:
--we will now FIRE (call) the event:
game.ReplicatedStorage.playAnim:FireServer(equipAnim,game.Players.LocalPlayer.Character.Humanoid)
-- make sure it is fire server and nothing else
end)
now insert a normal script into game.ServerScriptService and write this in it:
Well it could be an issue with the animation itself. Make sure that you own the animation, and that the animation is uploaded properly (i.e. load it in the animation editor and see if everything is right).
Other than that, I don’t know. You could try yielding for the player’s character to make sure it exists and everything is in place.
If all else fails try running it completely on a server script and if that works then we might have an issue here because it is supposed to replicate.
Pretty much just try and debug. Make sure the local script is running and that it gets to that line of code. Make sure the normal default animation script works. Try running an animation from the command line maybe.
If it works on the server but not on the client then you can just have your animations server side worst case scenario