Creating a "Sell Tool" Brick, fails. Why?
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!
01 | local player = game.Players.LocalPlayer |
02 | local plrgui = player:WaitForChild( "PlayerGui" ) |
03 | local bp = plrgui.Inventory.Backpack:GetChildren() |
04 | local gold = player.Leaderstats.Gold |
06 | items = "Hero Sword" , "Barbarian Sword" , "Elvish Warblade" , "Master Sword" , "Nightcrackle" , "Winterviel Staff" , "Wooden Sword" |
08 | if player.bp:FindFirstChild( "Hero Sword" ) then |
09 | gold.Value = gold.Value + 500 |
10 | player.bp:FindFirstChild( "Hero Sword" ):Destroy() |