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)

4 comments
The setup is so scary
Wow, this script is an artifact. I'm assuming you didn't write this, @Gamersofthegodss.
What do you mean?
Soooo many "enter"s.