I'm making a crouch script and it works fine for one player but if you have more, then any player can control the newest joined player. The animation will play only for this new player and nobody else. This is my script under ServerScriptService:
local walking = Instance.new("BoolValue")
walking.Value = false
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
wait(4)
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://5010278985"
Animate = player.Character.Humanoid:LoadAnimation(Animation)
wait()
local Animation2 = Instance.new("Animation", player.Character)
Animation2.Name = "Animation2"
Animation2.AnimationId = "rbxassetid://5062446283"
Animate2 = player.Character.Humanoid:LoadAnimation(Animation2)
end)
game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
if walking.Value == false then
walking.Value = true
Animate:Play()
end
end)
game.ReplicatedStorage.Crouch.End.OnServerEvent:Connect(function(player)
walking.Value = false
Animate:Stop()
Animate2:Stop()
end)
game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
player.Character.Humanoid.Running:Connect(function(speed)
if walking.Value == true and speed >= 1 then
Animate:Stop()
Animate2:Play()
end
end)
end)
game.ReplicatedStorage.Crouch.Start.OnServerEvent:Connect(function(player)
player.Character.Humanoid.Running:Connect(function(speed)
if speed <= 0 and walking.Value == true then
Animate2:Stop()
Animate:Play()
end
end)
end)
Instead of Animate:Play() or Animate:Stop() using my created animations is there a way to do
player.Character.Animate:Play()
I've just recently got into animations so any help is appreciated.

2 comments
The Animator instance on the humanoid enables automatic replication from both server sided animations and client-sided animations. This is not going to help.
Oh.