Next time, dont use a free model. Also, make sure this is in a local script if you are using local player.
01 | local player = game.Players.LocalPlayer |
02 | local Cash = player.leaderstats.Cash |
04 | local backpack = player.Backpack |
05 | local text = "Whatever the textbutton says right now" |
06 | script.Parent.MouseButton 1 Down:Connect( function (onClicked) |
07 | if Cash.Value > = price and backpack:FindFirstChild( "Sniper" ) = = nil then |
08 | Cash.Value = Cash.Value - price |
09 | local tool = script.Parent.Sniper:Clone() |
11 | local Tool = tool:Clone() |
12 | tool.Parent = player.StarterPack |
13 | elseif backpack:FindFirstChild( "Sniper" ) then |
14 | script.Parent.Text = "You already have that!" |
16 | script.Parent.Text = text |
17 | elseif Cash.Value < price then |
18 | script.Parent.Text = "You can't afford that!" |
20 | script.parent.Text = text |
22 | script.Parent.Text = "There was an error purchasing this!" |
24 | script.Parent.Text = text |
I'm assuming the sniper is a child of the text button, along with the script.