Ok so I’m making a mining game and I want to add an mining animation. The animation is in the tool. The animation was on the client side, and I fired it to the server side. By the way, this is a server script and the script was in the tool. Here’s the code:
wait(1)
local day = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name).Character.Humanoid:LoadAnimation(script.Parent.MiningAnimation)
print(script.Parent.Parent.Parent.Name)
game.ReplicatedStorage.AnimationLoader.OnServerEvent:Connect(function(Player, Pick,PlayStop)
print("FIRED")
if Pick == script.Parent then
print("IsPick")
if PlayStop == true then
print("ShouldPlay")
day:Play()
else
print("ShouldStop")
day:Stop()
end
end
end)
It should work, but it doesn’t. It doesn’t play the animation at all. It is firing and doing the correct things, but it’s not playing the animation. I have no idea why.
Oh I see your issue, you are trying to fire the animation from a server script. Since animations transfer from client to server you have to play it from a local script. You can’t play a animation from the server side, it has to be on the clients side.
local function playAnimationFromServer(character, animation)
local Humanoid = playerWhoFired.Character:FindFirstChildOfClass("Humanoid")
if Humanoid then
local animation = script.Animation
local animator = Humanoid:FindFirstChildOfClass("Animator")
if animator then
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()