game.ReplicatedStorage.AnimationPlayEvent.OnServerEvent:Connect(function(player, animationID) local Animation = Instance.new("Animation") Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation) LoadAnimation:Play() print("Played") game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID) LoadAnimation:Stop() print("Stopped") end) end) game.ReplicatedStorage.GlockAnimationEvent.OnServerEvent:Connect(function(player, animationID1) local Animation = Instance.new("Animation") Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID1 local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation) LoadAnimation:Play() print("Played") game.ReplicatedStorage.HoldAnimationEvent.OnServerEvent:Connect(function(player, animationID1) LoadAnimation:Stop() print("Stopped") local NewAnimation = Instance.new("Animation") NewAnimation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID1 local LoadNewAnimation = workspace[player.Name].Humanoid:LoadAnimation(NewAnimation) LoadNewAnimation:Play() print("Played") game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID1) LoadNewAnimation:Stop() print("Stopped") end) end) end) game.ReplicatedStorage.M1911AnimationEvent.OnServerEvent:Connect(function(player, animationID2) local Animation = Instance.new("Animation") Animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID2 local LoadAnimation = workspace[player.Name].Humanoid:LoadAnimation(Animation) LoadAnimation:Play() print("Played") game.ReplicatedStorage.HoldAnimationEvent.OnServerEvent:Connect(function(player, animationID2) LoadAnimation:Stop() print("Stopped") local NewAnimation = Instance.new("Animation") NewAnimation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID2 local LoadNewAnimation = workspace[player.Name].Humanoid:LoadAnimation(NewAnimation) LoadNewAnimation:Play() print("Played") game.ReplicatedStorage.UnequipAnimationEvent.OnServerEvent:Connect(function(player, animationID2) LoadNewAnimation:Stop() print("Stopped") end) end) end)
This is my OnServerEvent
script (In workspace) . I have 1 baton and 2 guns, 1 is named "Glock" and another is named "M1911". I was trying to make it so that when the baton or either of the 2 guns is equipped, it fires a RemoteEvent
which plays the animation.
But no matter what, it wont play the animation although it prints "Played" or "Stopped" in the output. I pressed f9 to check for error but theres none (in both Actual game and studio) .
Here are the fire RemoteEvent
scripts for baton, and the 2 guns.
Baton Script:
local tool = script.Parent tool.Equipped:Connect(function() wait() game.ReplicatedStorage.AnimationPlayEvent:FireServer("2639159960") print("Equip Animation Fired") end) tool.Unequipped:Connect(function() wait() game.ReplicatedStorage.UnequipAnimationEvent:FireServer() print("Unequip Animation Fired") end)
Glock Script:
local tool = script.Parent tool.Equipped:Connect(function() wait() game.ReplicatedStorage.GlockAnimationEvent:FireServer("02640284714") print("Glock Equip Event Fired") wait() game.ReplicatedStorage.HoldAnimationEvent:FireServer("02640561642") print("Hold Animation Event Fired") end) tool.Unequipped:Connect(function() wait() game.ReplicatedStorage.UnequipAnimationEvent:FireServer() print("Unequip Animation Fired") end)
M1911 Script:
local tool = script.Parent tool.Equipped:Connect(function() wait() game.ReplicatedStorage.M1911AnimationEvent:FireServer("02640284714") print("M1911 Equip Animation Fired") wait() game.ReplicatedStorage.HoldAnimationEvent:FireServer("02640561642") print("Hold Animation Fired") end) tool.Unequipped:Connect(function() wait() game.ReplicatedStorage.UnequipAnimationEvent:FireServer() print("Unequip Animation Fired") end)