UserInputService only working for one player

Hi! I’m currently making it so if you press ‘1’ on your keyboard, it equips a tool. (I’ve disabled the Core backpack UI.)

The problem is: I started a test with 2 accounts and had one account equip the tool in their backpack by pressing ‘1’. After, I tried equipping it on the second account, but it didn’t equip. No errors in output.

LocalScript
local Service = game:GetService("UserInputService")

Service.InputBegan:Connect(function(KeyboardInput)
	if KeyboardInput.KeyCode == Enum.KeyCode.One then
		game.ReplicatedStorage.Events:WaitForChild("ItemEquip"):FireServer()
	end
end)
Server Script
local Event = Instance.new("RemoteEvent")
Event.Name = "ItemEquip"
Event.Parent = game.ReplicatedStorage.Events

local Equipped = false
Event.OnServerEvent:Connect(function(Player)
	if Equipped == false then
		Player.Backpack:WaitForChild("Tool").Parent = Player.Character
		Equipped = true
	else
		Player.Character:WaitForChild("Tool").Parent = Player.Backpack
		Equipped = false
	end
	Player.Character.Humanoid.Died:Connect(function()
		Equipped = false
	end)
end)

Your Equipped variable is global in the ServerScript, so it applies for all players.

2 Likes