Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I force equip a gear?

Hello, I was wondering If there is anyway to force the player to equip a gear in the Backpack and not unequip it. Anything would help, thanks.

2 answers

✓ Accepted answer

This checks the character for any tools that are not supposed to be equipped and equips the tool with the name of ToolName

local Players = game:GetService("Players")
while true do
	wait()
	pcall(function()
		local ToolName = ("Name here")
		local Character = Players.LocalPlayer.Character
		local Humanoid = Instance.new("Humanoid")
		for i,v in pairs(Character:GetChildren()) do
			local t = {}
			if v:IsA("Tool") then
				table.insert(t,v)
			end
			if #t >= 2 then
				Humanoid:UnequipTools()
			end
		end
		Humanoid:EquipTool(Player:FindFirstChildOfClass("Backpack")[ToolName])
	end)
end

3 comments

0

It doesn't seem to be working for me. Is there anything I should make sure i'm doing?

0

Make it a LocalScript in StarterPlayer.StarterCharacterScripts?

0

I have Tried That, My tool is in StarterPack. Is that the right place?

you can find more information here

local Players = game:GetService("Players")

local player = Players:FindFirstChildOfClass("Players")
if player and player.Character then
    local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        local tool = game.ServerStorage:FindFirstChild("Tool")
        if tool then
            humanoid:EquipTool(tool)
        end
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.