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
So if i didn't get you wrong.. You made a Folder In the Player's Gui Called "Inventory" And Stored The Items in it.... Hmmm
Maybe Try Using a different Methods With Finding the Stored Items By Getting The Player's Character Then Item
... Example:
local player = game.Players.PlayerAdded:Connect(function(player) repeat wait() untill plr.Character local char = player.Character
Then
if char:FindFirstChild("TheItem")then gold.Value = gold.Value + 500 char:FindFirstChild("TheItem"):Destroy() end
Maybe this will Work
And btw Try Doing this in a ServerScript ( Put it in the Workspace )
First thing You Can't do game.players.LocalPlayer in a ServerScript Don't name Your items like this ("Hero Sword") Do it like that ("HeroSword") Maybe this will fix your Issue, If you consider Putting it with Spaces then put it like that ["Hero Sword"]
Example...:
if char:FindFirstChild["Hero Sword"] gold.Value = gold.Valie + 500 char["Hero Sword"]:Destroy()