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

[UNANSWERED]How do I cause tools to auto equip?

I'm trying to make a custom backpack, but I can't find a function for equipping/unequipping a tool. Could someone help? If so, thanks! I think this might work:

toolInBackpack:Equip()
--and for unequipping,
toolInBackpack:Unequip()

I can't test this myself because ROBLOX Studio's Play Solo is broken.

3 answers

✓ Accepted answer

A tool becomes equipped when it's parent is a character of a player.

With this being known, you can simply change the parent of the tool to the character when you want it to be equipped and to something else when you want it to be unequipped.

Example:

-- In this example I use the player's backpack as a place to store the tool, however the tool can be stored where ever you like.

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) -- This will disable all hotkeys for selecting tools along with removing the BackpackGui.

local player = game.Players.Player
local character = player.Character
local tool = player.Backpack.Tool

function equip(tool)
	tool.Parent = character
end

function unequip(tool)
	tool.Parent = player.Backpack
end

-- Simply call equip or unequip when you wish

6 comments

0

Awesome, thanks!

0

No problem :)

0

@MastaJames, I tried to move the tools parent into the character with one of my scripts, the tool just clips through my hand. Do I need to make joints?

0

It should automatically weld onto the characters arm...

0

If not you could weld it manually, for reference on how this could be accomplished check here: http://wiki.roblox.com/index.php?title=API:Class/Tool/Grip

0

For some reason it works and other times it doesn't Well thanks anyway!

Irrelevant question but does your solo crash too when you click stop and thats how its broken?

1 comment

1

Actually, yeah. It says "Debugger can be attatched to a module script"

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