When Part is touched the tool gets removed, but doesn't add 10 gold, and doesn't print text? [closed]
Asked by
8 years ago Edited 8 years ago
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"
05 | function getPlayer(humanoid) |
07 | local players = game.Players:children() |
11 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
25 | local human = part.Parent:findFirstChild( "Humanoid" ) |
27 | if (human ~ = nil ) and debounce = = false then |
35 | local player = getPlayer(human) |
39 | if (player = = nil ) then return end |
43 | user = game.Players:findFirstChild(human.Parent.Name) |
45 | local gold = player:WaitForChild( 'leaderstats' ).Gold |
47 | if player.Backpack:findFirstChild( "Wooden Sword" ) ~ = nil then |
51 | m = Instance.new( "Hint" ) |
53 | m.Text = "You sold your Wooden Sword for 10 gold!" |
57 | player.Backpack:findFirstChild( "Wooden Sword" ):remove() |
59 | gold.Value = gold.Value + 10 |
64 | m = Instance.new( "Hint" ) |
66 | m.Text = "You need the Wooden Staff to do this." |
90 | script.Parent.Touched:connect(onTouch) |