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

How can I search if a player has a gear, and removing the gear?

I do not know much about scripting. I had some problems and I was wondering if I can get some help. Thank you for those who attempt to answer this question. I appreciate it.

Okay... Lets say we have BRICK, and BRICK will contain the scripts. The Player has a gear that is named GEAR. BRICK also has a click detector. Once the click detector detects a click of the brick, the script would check if the player has GEAR equipped and pressing BRICK with GEAR. Once true, it would remove GEAR from the player's inventory.

How can I make that portion where is to check if the Player is using GEAR to click on BRICK, and How do I remove GEAR from the player?

Much Thanks.

2 comments

0

search backpack and character with FindFirstChildOfClass("Tool") and call :Destroy() on the return

0

You want it to only work when the tool is in his bag, or when the tool is activated (in his hands)

1 answer

✓ Accepted answer

The event you want to link to the ClickDetector is "MouseClick". The event returns the player who clicked the button. You would then delete "GEAR" from the Backpack of the player if it exists. The script looks something like this:

workspace.BRICK.ClickDetector.MouseClick:connect(function(player)	

--Now that you have the player and set the function to run when the event "MouseClick" occurs you can enter the function to delete the "GEAR" within the Backpack within the player.

end)

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