Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago
Edited 3 years ago

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)
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. superbubba2020 6 — 3y
0
no probs. I 'm not actually that skilled. I would say i'm intermediate in lua. NGC4637 602 — 3y
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! superbubba2020 6 — 3y
0
I tried your Dimension RPG out, i think it's pretty sick! you're way more skilled than i am superbubba2020 6 — 3y
0
thx NGC4637 602 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
0
If you have Questions or Some error, Please post It. sebtantin 15 — 3y
0
First it says, Player is not a valid member of DataModel "Testing my scripts" - Server - Prompt:3 superbubba2020 6 — 3y
0
I wrote It wrong UwU sebtantin 15 — 3y
0
Now is Apparently Solved, it Was "Players" not "Player". sebtantin 15 — 3y
View all comments (6 more)
0
it says 18:32:26.723 Workspace.Trashcan.Attachment.Prompt:3: attempt to index nil with 'BackPack' - Server - Prompt:3 superbubba2020 6 — 3y
0
Ok, I'll Check that. sebtantin 15 — 3y
0
wait, i accidently did BackPack and not Backpack superbubba2020 6 — 3y
0
Do i put this script in a localscript? or just a normal? superbubba2020 6 — 3y
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 NGC4637 602 — 3y
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 NGC4637 602 — 3y

Answer this question