How do I make a Proximity Prompt that Deletes a Tool (Trash Can)

Hi There! I need some help. I want to create a Proximity Prompt that when Activated Deletes an entire inventory for a cafe game! If you could help me please lmk.

Also if I put this in the wrong category please let me know. I’m still new to the dev forum.

Best Regards,
@postmodernSky

4 Likes

Please put this in #help-and-feedback:scripting-support

1 Like

This should be in #help-and-feedback:scripting-support. Press the pencil icon and change the category

Also for the thing, you could make it so whoever interacts with the Prompt, it unequips their tools and removes all the stuff in the backpack.

The Triggered event for ProximityPrompts works wonders for it, as it returns the player who triggered the prompt, you can use that returned player to get the Character’s Humanoid, and use UnequipTools(), and then go through the player’s backpack and destroy all the tools in there

1 Like
proximitypropt.triggered:connect(function()
   tool:destroy()
)

Thank You! I will try that now

if you just copy and paste it aint gonna work it was just example code

Ok! I will talk to my friend that scripts. Thank You for the help.

1 Like

That will not work at all, there’s a lot of typos and incorrect syntaxing, also tool is not specified, you can’t just go off copy and pasting, we’re giving you ways to actually do what is needed

  • When the prompt is triggered,
  • Use the player it gives you and get the character via .Character, and then get the Humanoid from that character
  • Use :UnequipTools() on the Humanoid
  • Loop through the player’s backpack and destroy everything there via :Destroy()

Place a local script inside starterplayerscripts.

local player = game:GetService("Players").LocalPlayer


proximityPrompt.Triggered:Connect(function()
    
    for _, item in pairs(player.Backpack:GetChildren()) do
        item:Destroy()
    end
end)

I am not sure if this is what you want btw.

1 Like

@OP wanted a Proxmityprompts that can destroy all the tools you own, that will not work for what they want

Also, @Mysterious_Myth11 it’s better to put it as a reglar script in the prompt itself and use the return Triggered gives instead, also it wont account if the player is holding a tool, so you have to make it unequip any tools the player is holding and then destroy

2 Likes

Thank you for the help! But what I’m trying to do is when a Trash Can Mesh’s Proximity Prompt is triggered. It deletes the inventory of the player.

1 Like

What do you mean inventory. Player inventory?

CoreGui.Enum Backpack I think.

Yes Like the Players Inventory.

1 Like

it probably is, but, did you make a variable for the proximity prompt? or this is the whole script

No because I don’t know where it’s located.

Simplest way to do it would be this

local prompt = script.Parent

prompt.Triggered:Connect(function(player)
	local backpack = player.Backpack
	
	local char = player.Character
	if not char then return end
	
	local hum = char.Humanoid
	hum:UnequipTools()
	wait()

	for _,tool in pairs(backpack:GetChildren()) do
		tool:Destroy()
	end
end)

Script i nthe proximityprompt

3 Likes

don’t she means the tools in it? btw if it is the backpack gui it’d be sorta useless ngl

Ok! Let me try that right now. Thank You :D.

2 Likes

make sure the scripts parent is the ProximityPrompts

2 Likes