How to force equip a players tool

Hello,

So I’ve been making a sword fighting game, and when you enter the arena, I just can’t seem to figure out how to force the player to use the tool.

Objective:

I need to force the player to use the tool, but the tool is in the players StarterGui. How can this work?

8 Likes

Get their Humanoid and use Humanoid:EquipTool(x) replace “x” with the tool Instance.

2 Likes

Could you give me a code example, let’s say the tool is in startergui. The script is currently inside startergui. It is a server-sided script though.

local tool = -- tool here

for _, plr in pairs(game.Players:GetPlayers()) do
   -- loops through all the players in the game
  coroutine.wrap(function() -- this is so that other players can get the tool and wouldn't have to wait for someone
      local t = tool:Clone() -- clones the tool
      local char = plr.Character or plr.CharacterAdded:Wait() -- gets the player's character
      local hum = char:FindFirstChildOfClass("Humanoid") -- get the humanoid

      hum:EquipTool(t) -- force equip the tool
  end)()
end
39 Likes

does this work on the client???

I’ve only ever used this behavior on the server, but it should work on the client (assuming you’re only using Humanoid:EquipTool() on the LocalPlayer’s Humanoid).

2 Likes

thank you for responding immediately even after 4 years :saluting_face:

8 Likes