0

# How do I find a local playertool by name?

Hello, I have added a proximity prompt to a part and when used, it sells the item you currently have. I made this by creating a "Tools" folder in the proximityprompt, followed by a Boolvalue (Name of tool) and Numbervalue (Price of tool)

So the structure looks like this:

Part - Proximityprompt -- Tools (Folder) --- Sword (Boolvalue) ---- Price (Numbervalue)

Now I have been stuck with on prohibitng from selling certain items. Lets say we have a tool named "Sword1", and I want that everything can be sold except for this "Sword1", how should I do that? I have tried with "if..." scripts but I cannot figure out what I am doing wrong.

Below you can find the script.

local prox = script.Parent

prox.Triggered:Connect(function(player)
for i, tools in pairs(prox.Tools:GetChildren()) do
if player.Character:FindFirstChild(tools.Name) then

player.Character:FindFirstChild(tools.Name):Destroy()
end
end
end)


0
Does the code you showed above work? It doesn’t look like it has the prohibiting part that you want to add, if it does work, then I can add the prohibiting part. manith513 81 — 11d

0
Edited 11 days ago
local prox = script.Parent

prox.Triggered:Connect(function(player)
for i, tools in pairs(prox.Tools:GetChildren()) do
if player.Character:FindFirstChild(tools.Name) and tools.Name ~= "Sword1" then