How do I make a trash can with a proximity prompt?

Hello, fellow developers! I am asking for some help on something small.

At the moment, I’m trying to create a trash can for my café game that can delete a selected (equipped) item from a user’s inventory. Unfortunately, I have not found much help around.

If you can help, please let it be a proximity prompt that can be activated to do the following above.

Best regards,
@DestinedKismet

(I accidentally posted the false version on a Bulletin Board, my bad.)

Maybe you could make it so when the player presses the proximity prompt it fires a remote event which deletes all the players items in their backpack? Not sure tho

1 Like

I can try that. I have it only as a prompt. Here’s the photo.

image

Try avoiding asking for code in #help-and-feedback:scripting-support and post that in #collaboration:recruitment.

Here is code that goes inside a script (not a LocalScript) parented to a proximity prompt:

local proximityPrompt = script.Parent
proximityPrompt.Triggered:Connect(function(player)
    local character = player.Character
    if not character then
        return
    end
    
    local tool = character:FindFirstChildOfClass("Tool")
    if not tool then
        return
    else
        tool:Destroy()
    end
end)
3 Likes

Thanks. I’ll remember next time to put in the correct location, as this is my first post. Again, thank you a bundle.

1 Like