Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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:

1toolInBackpack:Equip()
2--and for unequipping,
3toolInBackpack:Unequip()

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

3 answers

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

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:

01-- 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.
02 
03game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) -- This will disable all hotkeys for selecting tools along with removing the BackpackGui.
04 
05local player = game.Players.Player
06local character = player.Character
07local tool = player.Backpack.Tool
08 
09function equip(tool)
10    tool.Parent = character
11end
12 
13function unequip(tool)
14    tool.Parent = player.Backpack
15end
16 
17-- Simply call equip or unequip when you wish
0
Awesome, thanks! ChipioIndustries 454 — 10y
0
No problem :) BlackJPI 2658 — 10y
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? EzraNehemiah_TF2 3552 — 10y
0
It should automatically weld onto the characters arm... BlackJPI 2658 — 10y
View all comments (2 more)
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 BlackJPI 2658 — 10y
0
For some reason it works and other times it doesn't Well thanks anyway! EzraNehemiah_TF2 3552 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

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

1
Actually, yeah. It says "Debugger can be attatched to a module script" ChipioIndustries 454 — 10y
Log in to vote
0
Answered by 5 years ago

https://developer.roblox.com/api-reference/function/Humanoid/EquipTool and it's counter part https://developer.roblox.com/api-reference/function/Humanoid/UnequipTools

Answer this question