Script for animation does not work

I am trying to make some power gloves and they have 2 guns that move and i am trying to fix the animation. the first time i open the gloves they work fine but second time there is a small movement that i dont want

Priorities for animations
animation idle - action2
animation in idle-action2
animation -action1
animation in-action1


animations that play during the first and second opening, during the closing of animationinidle and animationidle (2 for each opening)
Screenshot 2024-10-30 104705

Script in local script in starter character scripts

local state = false
local moving = false


local UserInputService = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed then
		if input.KeyCode == Enum.KeyCode.E then
			if state == false and moving == false then
				moving = true
				state = true
				RS.AnimationStop:FireServer("AnimationInIdle")
				RS.Animation:FireServer("Animation")
				wait(1)
				RS.Animation:FireServer("AnimationIdle")
				moving = false
			else if state == true and moving == false then
					moving = true
					state = false
					
					RS.Animation:FireServer("AnimationIn")
					wait(1)
					RS.AnimationStop:FireServer("AnimationIdle")
					RS.Animation:FireServer("AnimationInIdle")
					






					moving = false
				end
			end
		end
	end
end)

script in script in server script service containing remotes

local remote = Instance.new("RemoteEvent")
remote.Name = "Animation"
remote.Parent = game.ReplicatedStorage
local remote2 = Instance.new("RemoteEvent")
remote2.Name = "AnimationStop"
remote2.Parent = game.ReplicatedStorage

remote.OnServerEvent:Connect(function(player, info)
	local hum = player.Character.Humanoid
	local anim = hum:LoadAnimation(script:FindFirstChild(info))
	--print(anim.Name.."play")
	anim:Play()
	anim:AdjustSpeed(1)
end)

remote2.OnServerEvent:Connect(function(player, info)
	local hum = player.Character.Humanoid
	local anim = hum:LoadAnimation(script:FindFirstChild(info))
	local animator = hum:FindFirstChildOfClass("Animator")
	for i,v in pairs(animator:GetPlayingAnimationTracks()) do
		if v.Name == info then
		v:Stop()
		end
	end
	
	print(player.Character.Humanoid:GetPlayingAnimationTracks())
end)