Value is not changing

Hello, why my value is still true ? Sometimes it works but I do not know why there is this problem.

  13:48:36.263  true  -  Client - ManagementInv:18
  13:48:36.296  true  -  Client - ManagementInv:34
local uis = game:GetService("UserInputService")
local p = game:GetService("Players").LocalPlayer

local rs = game:GetService("ReplicatedStorage")

local Equip_ARI = script:WaitForChild("Equip_ARI")

uis.InputBegan:Connect(function(code, _gp)
	if code.KeyCode == Enum.KeyCode.One and not _gp then
		local character = p.Character
		local humanoid = character:FindFirstChild("Humanoid")
		
		local mWeapon = rs.Events.Inventory.GetMainWeapon:InvokeServer()
		if mWeapon == "ARI" then
			local isEquipped = rs.Events.Items.GetARIEquipped:InvokeServer()
			local EquipAnimTrack_ARI = humanoid.Animator:LoadAnimation(Equip_ARI)
			if isEquipped then
				print(rs.Events.Items.GetARIEquipped:InvokeServer())
				
				local tracks = humanoid:FindFirstChildOfClass("Animator"):GetPlayingAnimationTracks()
				for i,v in pairs(tracks) do 
					if v.Name == "Equip_ARI" then
						v:Stop()
					elseif v.Name == "Block_ARI" then
						v:Stop()
					elseif v.Name == "Reload_ARI" then
						v:Stop()
					elseif v.Name == "Shoot_ARI" then
						v:Stop()
					end
				end
				rs.Events.Items.RemoveItem:FireServer("ARI")
				rs.Events.Items.SetARIEquipped:FireServer(false)
				print(rs.Events.Items.GetARIEquipped:InvokeServer())
			else 
				rs.Events.Items.GiveItem:FireServer("ARI")
				rs.Events.Items.SetARIEquipped:FireServer(true)
				EquipAnimTrack_ARI:Play()
			end
		end
	end
end)

To avoid problems I check it from the client.

local uis = game:GetService("UserInputService")
local p = game:GetService("Players").LocalPlayer

local rs = game:GetService("ReplicatedStorage")

local Equip_ARI = script:WaitForChild("Equip_ARI")

uis.InputBegan:Connect(function(code, _gp)
	if code.KeyCode == Enum.KeyCode.One and not _gp then
		local character = p.Character
		local humanoid = character:FindFirstChild("Humanoid")
		
		local mWeapon = rs.Events.Inventory.GetMainWeapon:InvokeServer()
		if mWeapon == "ARI" then
			local isEquipped = p.Character:FindFirstChild("ARI")
			local EquipAnimTrack_ARI = humanoid.Animator:LoadAnimation(Equip_ARI)
			if isEquipped then
				local tracks = humanoid:FindFirstChildOfClass("Animator"):GetPlayingAnimationTracks()
				for i,v in pairs(tracks) do 
					if v.Name == "Equip_ARI" then
						v:Stop()
					elseif v.Name == "Block_ARI" then
						v:Stop()
					elseif v.Name == "Reload_ARI" then
						v:Stop()
					elseif v.Name == "Shoot_ARI" then
						v:Stop()
					end
				end
				rs.Events.Items.RemoveItem:FireServer("ARI")
			else 
				rs.Events.Items.GiveItem:FireServer("ARI")
				EquipAnimTrack_ARI:Play()
			end
		end
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.