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

I need to check if a Tool in the inventory is selected without using Tool.Equipped?

Asked by 5 years ago

So, I wanted to create a tool, similar to in Arcane Adventures, where when you have it selected and press a button, it executes a magical attack.

So, in order to find out when the player has the tool equipped or unequipped, I used the "Tool.Equipped" function. As it turns out, the "Tool.Equipped" function only works if the tool in question has a Handle part. Which I don't want.

Is there a reliable way to find out if a tool is selected without using Tool.Equipped?

Thank you!

2 answers

Log in to vote
1
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago
Edited 5 years ago

Actually, yes! When you equip a tool, the tool's parent becomes your character, meaning you can create a variable called IsEquipped, and creating an event detecting if the Tool's parent is in the character. Hope this helped!

0
So if the tools parent is the character's parent its parent is the workspace? User#19524 175 — 5y
0
Oops let me fix that Mr_Unlucky 1085 — 5y
0
Ah, I see! When you select a tool, it is parented to the character. So if the tool's parent is not the character, the player hasn't selected it, but if it is, the player has it selected currently. Thanks for the info! OrcaTheFish 95 — 5y
0
No problem! Mr_Unlucky 1085 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

First, Equipped is not a function, it is an event. You can check if a tool is equipped by checking the character. When a tool is equipped, it gets parented to the character, and when unequipped, it goes back into the backpack. Also, you can check if a tool is equipped without a Handle part. Set the RequiresHandle property of your Tool to false.

Answer this question