Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is This "Buy" Script Incorrect, The output says nothing and it does nothing when I play?

Asked by 4 years ago
01player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
02price = 30
03coin = player.leaderstats.Simucoins
04tool = game.ServerStorage.BShopUpgrades:FindFirstChild("RoTopR")
05info = script.Parent.Parent
06 
07function BuyU1()
08    if coin.Value >= price then
09        coin.Value = coin.Value - price
10        local clone = tool:Clone()
11        clone.Parent = player.Backpack
12        local clone2 = tool:Clone()
13        clone2.Parent = player.StarterGear
14        script.Disabled = true
15    end
16end
17 
18script.Parent.MouseButton1Click:Connect(BuyU1)

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).

0
Is this a Localscript? hzesbemad 24 — 4y
0
this was a normal script UltraMegaVicninja 4 — 4y
0
I will try a local script UltraMegaVicninja 4 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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:
02local Player = game.Players.LocalPlayer
03local Price = 30
04local Coin = Player.leaderstats:WaitForChild("Simucoins")
05local Tool = game.ReplicatedStorage.BShopUpgrades:FindFirstChild("RoTopR")
06 
07script.Parent.MouseButton1Click: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
17end)

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

Ad

Answer this question