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
player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
price = 30
coin = player.leaderstats.Simucoins
tool = game.ServerStorage.BShopUpgrades:FindFirstChild("RoTopR")
info = script.Parent.Parent

function BuyU1()
    if coin.Value >= price then
        coin.Value = coin.Value - price
        local clone = tool:Clone()
        clone.Parent = player.Backpack
        local clone2 = tool:Clone()
        clone2.Parent = player.StarterGear
        script.Disabled = true
    end
end

script.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:

-- Locals:
local Player = game.Players.LocalPlayer
local Price = 30
local Coin = Player.leaderstats:WaitForChild("Simucoins")
local Tool = game.ReplicatedStorage.BShopUpgrades:FindFirstChild("RoTopR")

script.Parent.MouseButton1Click:Connect(function()
    if Coin.Value > Price then
        Coin.Value = Coin.Value -Price
        Tool:Clone().Parent = Player.Backpack
        Tool:Clone().Parent = Player.StarterGear
        print("Bought") -- Prints
        script.Disabled = true
    else
        print("You Need "..Price -Coin.Value) -- If you don't have enough it will print how much you need
    end
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

Ad

Answer this question