01 | player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent |
02 | price = 30 |
03 | coin = player.leaderstats.Simucoins |
04 | tool = game.ServerStorage.BShopUpgrades:FindFirstChild( "RoTopR" ) |
05 | info = script.Parent.Parent |
06 |
07 | function BuyU 1 () |
08 | if coin.Value > = price then |
09 | coin.Value = coin.Value - price |
10 | local clone = tool:Clone() |
11 | clone.Parent = player.Backpack |
12 | local clone 2 = tool:Clone() |
13 | clone 2. Parent = player.StarterGear |
14 | script.Disabled = true |
15 | end |
16 | end |
17 |
18 | script.Parent.MouseButton 1 Click:Connect(BuyU 1 ) |
Whenever I press the button, my currency hasn't been taken and i haven't got my item. I'm confused, when i looked at my output it turned no results.
For My Gui: HShopGui (ScreenGui) > Frame (Frame) > Info (Frame) > BuyU1 (TextButton) > BuyUpgrade1 (Script).
Hello I didn't know if you're Code was a Script or LocalScript so I made you a script that I tested and works. It is more different than yours, but people have different styles of Coding/Scripting.
Script:
01 | -- Locals: |
02 | local Player = game.Players.LocalPlayer |
03 | local Price = 30 |
04 | local Coin = Player.leaderstats:WaitForChild( "Simucoins" ) |
05 | local Tool = game.ReplicatedStorage.BShopUpgrades:FindFirstChild( "RoTopR" ) |
06 |
07 | script.Parent.MouseButton 1 Click:Connect( function () |
08 | if Coin.Value > Price then |
09 | Coin.Value = Coin.Value -Price |
10 | Tool:Clone().Parent = Player.Backpack |
11 | Tool:Clone().Parent = Player.StarterGear |
12 | print ( "Bought" ) -- Prints |
13 | script.Disabled = true |
14 | else |
15 | print ( "You Need " ..Price -Coin.Value) -- If you don't have enough it will print how much you need |
16 | end |
17 | end ) |
By the way just to let you know this isn't a Script this is an Localscript enjoy!
If you need anymore help add me on ROBLOX or just add me on discord hoesbemad.#8403