Preventing a Tool From Being Picked Up

Here’s the scenario. I have a tool in my game that starts out behaving normal. It works fine. When I put it down somewhere, however, I don’t want it to be picked up on contact. I want the player to click on the tool instead.

I thought I had the solution. As soon as the player put the tool down, I renamed the Handle to HandleDisabled. That would prevent contact pick-up. Once they clicked the tool, I put it in the player’s backpack, renamed HandleDisabled back to Handle and equipped it.

Apparently, I didn’t test enough, because I just found my player picking up the tool on contact even though the Handle was renamed. After troubleshooting, it looks like if the tool enters the game with a part named Handle, it doesn’t matter if you rename it. The game knows that part is the tool’s handle.

Has anyone else tried to do something similar?

2 Likes

You could clone a tool at the place the character put it down, set the CFrame to the tool, and delete the actual tool. And just have a click detector in the “fake” cloned tool, and once they pick it up, the fake tool gets destroyed, and they get a real tool in their backpack

1 Like

Maybe you could name the “Handle” not “Handle” while it’s on the ground. Then you could add a script that would rename the handle “Handle” and call Humanoid:EquipTool() for the tool when it is clicked. Then, when it detects it has been dropped (with Instance.AncestryChanged), rename the handle back to not “Handle”

EDIT: Well that didn’t seem to work. You’re better off using @DarkDanny04’s method.
EDIT: Also I’m dumb and not realize that’s the method you used.

You can turn off letting player grab the tool when it touches it in the properties.
You can add a click detector in the tool, when it’s clicked, the tool is cloned into their backpack and the tool on the ground can be moved to a different folder or destroyed.

1 Like

where exactly are the properties? i don’t see anything relating to letting the player grab the tool in the tool properties

Turn off CanBeDropped. If you want a player to drop it using backspace, then CanBeDropped doesn’t work.

That’s for disabling the tool being dropped. What ColaCoder wants is for the tool to not be picked up on touch.

If a tool cannot be dropped, it cannot be picked up.

I set a tool’s CanBeDropped to false and i playtested the game and I successfully picked up the tool on contact.

You could parent the tool’s handle to workspace, and delete the tool instance.

Have you tried disabling the tool?

Thank you for the suggestions! Yes, I’ve tried disabling as well as messing around with the CanBeDropped property. I was also hoping that ManualActivationOnly was the trick, but that’s if you are already holding the tool. I’m going to try DarkDanny04’s suggestion and see what I come up with. I’ll let you know!

OK @DarkDanny04, it looks like that’s going to work! Unfortunately, it complicates my code a bit, but what can you do.

It does make me wonder if I’m making this too complicated. The whole reason behind this was to prevent the player accidentally picking up all the tools as they walked past them. Picture a pegboard with hanging tools on it that you can walk right up to and look at, but you don’t want the player picking them up unless they specifically want to. Is there a simpler way?

oh! You could try removing the TouchInterest from the handle of the tool when you set it down

4 Likes

That works! And the resulting rework in my code is minimal and cleaner. I didn’t even think about TouchInterest because you don’t see it in the part hierarchy until the game is being played. Thank you very much for the help!

1 Like

The dev hub says that if you remove the touch transmitter, the event listening to the touch event will not be cleaned up. This might cause performance issues over time.

Oh man. Well, thanks for that info. I looked up the page you are talking about and it does say you can “disconnect the connection using RBXScriptConnection/Disconnect” to avoid that issue. I’ll have to look into what that means.

That means calling connection:Disconnect(). Unfortunately, I don’t think you can disconnect the connection for tool pickup yourself.