Could I get some help with my script? I made a surface Gui shop using Coins as money but when I click the button it doesn't give me my item or spend the Coins for it. here's the script
repeat wait() Player = game.Players.LocalPlayer Button = script.Parent Item = game.ReplicatedStorage:FindFirstChild("BloxyCola") Cost = 25 Coin = Player.leaderstats.Coins until Button.MouseButton1Down:connect(function(purchase) if Coin.Value > (Cost - 1) then Coin.Value = Coin.Value - Cost local a = Item:Clone() a.Parent = Player.Backpack local b = Item:Clone() b.Parent = Player.StarterGear end end)
Oh and here's where the script is. (Sign.SurfaceGui.TextButton.LocalScript)
First, I suggest you use MouseButton1Click. As far as I know, both events don't return anything, so purchase = nil. StarterGear is not part of a player. That's only in Studio.
Cost = 1 Item = game.ReplicatedStorage.BloxyCola Button.MouseButton1Click:connect(function() game.Players.LocalPlayer.leaderstats.Coins.Value = game.leaderseats.Coins.Value - Cost Item:Clone().Parent = game.Players.LocalPlayer.Backpack end) -- this should work now