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

How to execute a ProximityPrompt script that destroys the item you have equipped?

I'm trying to make a Trashcan that has a Proximity Prompt, that let's you destroy the tool that you have currently equipped. I need help finishing this script.

local KeyPart = script.Parent local Prompt = KeyPart.ProximityPrompt

Prompt.Triggered:Connect(function(player) local bp = player.Backpack if bp:FindFirstChild("Keycard") then --- then what??

end

end)

2 answers

✓ Accepted answer

edit: nvm i see you are doin something different

local KeyPart = script.Parent
local Prompt = KeyPart.ProximityPrompt

Prompt.Triggered:Connect(function(player)
	local chr = game.Workspace:FindFirstChild(player.Name)
	if chr:FindFirstChildWhichIsA("Tool") then
		chr:FindFirstChildWhichIsA("Tool"):Destroy()
	else
		return
	end
end)

5 comments

0

bro, you are such a legend. you are a miracle worker! like man thanks for the past 2 scripts. you are big brain. and i praise you for that! this will help me out in the future.

0

no probs. I 'm not actually that skilled. I would say i'm intermediate in lua.

0

compared to me, you're way more skilled than I am. I started to learn about lua like a week ago, so i don't know that much compared to you. but anyways, thanks alot!

0

I tried your Dimension RPG out, i think it's pretty sick! you're way more skilled than i am

0

thx

Well, you have to be More especific, but, From what i understand, I've created a Script to make it.

local Proximity = script.Parent --Here the Localization of the Proximity Prompt.
local Stuff = " " --Here the Tool name from a String.
local BackPack = game.Players.LocalPlayer.Backpack

Proximity.Triggered:Connect(function()
    if BackPack:FindFirstChild(Stuff) then
        BackPack:FindFirstChild(Stuff):Destroy()
    else
        print("There is nothing :/")
    end
end)

10 comments

0

If you have Questions or Some error, Please post It.

0

First it says, Player is not a valid member of DataModel "Testing my scripts" - Server - Prompt:3

0

I wrote It wrong UwU

0

Now is Apparently Solved, it Was "Players" not "Player".

0

it says 18:32:26.723 Workspace.Trashcan.Attachment.Prompt:3: attempt to index nil with 'BackPack' - Server - Prompt:3

0

Ok, I'll Check that.

0

wait, i accidently did BackPack and not Backpack

0

Do i put this script in a localscript? or just a normal?

0

dude, scripts cannot do local player :vvvvvvv and local scripts don't work outside the player and player's character. You have to make use of the triggered event's parameter called player

0

dude, scripts cannot do local player :vvvvvvv and local scripts don't work outside the player and player's character. You have to make use of the triggered event's parameter called player which returns the player who triggered the prompt

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