The part that works is the part where it gets rid of the item in the backpack on touch but doesn't give gold for it (a sell weapon button). And it also doesn't print the message saying "you bought this for 100" or "you don't have that weapon"
local debounce = false function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouch(part) local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then debounce = true local player = getPlayer(human) if (player == nil) then return end user = game.Players:findFirstChild(human.Parent.Name) local gold = player:WaitForChild('leaderstats').Gold if player.Backpack:findFirstChild("Wooden Sword") ~= nil then m = Instance.new("Hint") m.Text = "You sold your Wooden Sword for 10 gold!" m.Parent = player player.Backpack:findFirstChild("Wooden Sword"):remove() wait(2) gold.Value = gold.Value + 10 m.Parent = nil else m = Instance.new("Hint") m.Text = "You need the Wooden Staff to do this." m.Parent = player wait(3) m.Parent = nil end wait(2) debounce = false end end script.Parent.Touched:connect(onTouch)
Closed as Non-Descriptive by Goulstem
This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.
Why was this question closed?