Humanoid:EquipTool only working for one player

  1. What do you want to achieve?
    I’m trying to make a thing where when a player joins the game, it automatically equips a tool called “Tool” in workspace.

  2. What is the issue?
    It works fine for the first person who joins the game. After that though, nobody else gets the tool.

  3. What solutions have you tried so far?
    I tried This article on the developer hub, but the script they gave had the exact same problem.

There are no errors in the output either
Code:

game.Players.PlayerAdded:Connect(function(plr)
	local player = plr.Name --get players name
	local playerInWorkspace = game.Workspace:WaitForChild(player) --wait for player to appear in workspace (game.Workspace[player]...)
	local hum = game.Workspace[player]:WaitForChild("Humanoid") --wait for humanoid in the player
	local tool = workspace:FindFirstChild("Tool") --wait for a tool named "Tool" to load in workspace
	hum:EquipTool(tool) --equip it
end)

You will want to clone the tool that you are going to give to a player because you are referencing a single tool which will be removed from workspace after being equipped by the first player.

game.Players.PlayerAdded:Connect(function(plr)
	local character = player.Character or player.CharacterAdded:Wait()-- get player character 
	local hum = character:WaitForChild("Humanoid") --wait for humanoid in the player
	local tool = workspace:WaitForChild("Tool"):Clone() --wait for a tool named "Tool" to load in workspace
	hum:EquipTool(tool) --equip it
end)

Also if you’re trying to give it to them every time they spawn then you should just put the tool in the StarterPack or the player’s personal StarterPack–no code required.

1 Like