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.
01 | local prox = script.Parent |
03 | prox.Triggered:Connect( function (player) |
04 | for i, tools in pairs (prox.Tools:GetChildren()) do |
05 | if player.Character:FindFirstChild(tools.Name) then |
06 | player.leaderstats.Cash.Value + = tools.Price.Value |
08 | player.Character:FindFirstChild(tools.Name):Destroy() |