Hello all, I am creating a Sell Tool system, via bricks, that detect if a tool is in my custom inventory (in the PlayerGui), and if they step on said brick, and the code detectsthat it's in there, it removes it, and gives them their respected amount in Gold for selling their item.
I've done some research, tried a few methods, but cannot seem to nail this one! My inventory is in the PlayerGui and has a model in it that has the items stored inside it. I have tried to connect this LocalScript inside of the brick, and tried with a ServerScript and neither have worked!
Any and all help with this is appreciated! Thank you!
local player = game.Players.LocalPlayer
local plrgui = player:WaitForChild("PlayerGui")
local bp = plrgui.Inventory.Backpack:GetChildren()
local gold = player.Leaderstats.Gold
items = "Hero Sword", "Barbarian Sword", "Elvish Warblade", "Master Sword", "Nightcrackle", "Winterviel Staff", "Wooden Sword"
if player.bp:FindFirstChild("Hero Sword")then
gold.Value = gold.Value + 500
player.bp:FindFirstChild("Hero Sword"):Destroy()
end

3 comments
This never worked, as there's no ontouched function to coexist with the code! I had just seen I had forgotten to add this function. As well, the items in the inventory are stores in the PlayerGui in a model inside the Gui. And when equipped, they're placed as a "tool" in the plr char.
Don't Just copy and paste these Codes, These are just Example, Try Understanding The script and then, Redo it in your own way
Ahh. Alright.