So, basically I am working on a FPS game, and I made a custom tool system of my own. Now, for whatever reason ( not sure if this was happening before I switched or not ), when a player switches to a different weapon, all the other players' animations stop. I've tested this in a live game and in studio.
This is the code in a server script. There's nothing wrong on the client end, trust me lol.
replicatedStorage.Weapons.Melee.MeleeSwingEvent.OnServerEvent:Connect(function(player, tool, animation)
local fireAnim = tool.Parent.Humanoid:LoadAnimation(animation)
fireAnim:Play()
tool.WeaponDetails.Swinging.Value = true
tool.FireSound:Play()
end)
replicatedStorage.Weapons.EquipAnimation.OnServerEvent:Connect(function(player,animation, idleAnimation, tool)
local newAnim = workspace[player.Name].Humanoid:LoadAnimation(animation)
newAnim:Play()
local idleAnimationLoaded = workspace[player.Name].Humanoid:LoadAnimation(idleAnimation)
idleAnimationLoaded:Play()
tool.EquipSound:Play()
replicatedStorage.Weapons.UnequipAnimation.OnServerEvent:Connect(function(player)
newAnim:Stop()
idleAnimationLoaded:Stop()
for i,v in pairs(workspace:GetChildren()) do
if v.Name == player.Name.."'s Trajectory" then
v:Destroy()
end
end
end)
replicatedStorage.Weapons.Reload.OnServerEvent:Connect(function(player,animation)
if animation.Parent.ReloadSound.Playing == false then
animation.Parent.ReloadSound:Play()
local reloadAnim = workspace[player.Name].Humanoid:LoadAnimation(animation)
reloadAnim:Play()
end
end)
end)

3 comments
I'm confused of what you're talking about here. If the player switches off the weapon, the holding animation HAS to stop so I can't just disconnect those.
I'm not saying do what I did, i'm saying all that I highlighted is connected due to some ends being in the wrong place.
It works now when the reload animation starts in one player, but still not when a player unequips or equips another weapon.