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?
4 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
21 Likes