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

Click Buy Brick Color Gui Isn't Working And Not Sure Why, Would You Please Help Me?

Asked by 5 years ago
Edited 5 years ago

This isn't working and I'd like to know why. This script is supposed to function to where, when a gui is clicked, you buy color for a brick. I'm not sure what the problem is, please help me. Edit: Would someone please help?

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local cash = Instance.new("IntValue")
moneyToGive = -60
print "line 5"
function onclick()
    if cash.Value < 60 then
        script.Sound2:Play()
    end
    if cash.Value >= 60 then
        cash.Value = cash.Value + moneyToGive
        script.Sound:Play()
        print "line 14"
        game.Workspace.Desperado.Body.BD.BrickColor = BrickColor.new("Storm blue")
        game.Workspace.Desperado.Body.TailG.BrickColor = BrickColor.new("Storm blue")
    end
end
script.Parent.MouseButton1Click:connect(onclick)
0
Why are the leaderstats being created on the client User#19524 175 — 5y
0
I don't know, I was confused when I was working on this. I don't know how to do it though. Darkcraft10 20 — 5y

1 answer

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

Problems: - how does this bold thing work?(edit: oh.) The leaderstats you were trying to create were not going into the player. Also, some minor bugs and you said something about when a GUI is clicked but used BrickColor. Try using Color3. And I have no idea what is going on with the adding -60 cash to a player but okay. And let me know if it doesn't work.

game.Players.PlayerAdded:Connect(function(Player)
    local leaderstats = Instance.new("Folder",Player)
    leaderstats.Name = "leaderstats"
    local Cash = Instance.new("IntValue")
    Cash.Name = "Cash"
    Cash.Value = 0
end)

moneyToGive = -60 -- moneyToGive -60 lol moneyToTake -60
print("Line 2")
local Player = game.Players.LocalPlayer
local cash = "Cash"
script.Parent.MouseButton1Click:Connect(function() -- MouseButton1Click only works for GUI buttons.
    if Player.leaderstats ~= nil then
        if Player.leaderstats[cash].Value < 60 then
        script.Sound2:Play()
    else
    if Player.leaderstats[cash].Value >= 60 then
        Player.leaderstats[cash].Value = Player.leaderstats[cash].Value + moneyToGive -- moneyToGive - 60? so if current cash i 100 then adding - 60 will ??? 40?
        script.Sound:Play()
        game.Workspace.Desperado.Body.BD.BrickColor = BrickColor.new("Storm blue")
        game.Workspace.Desperado.Body.TailG.BrickColor = BrickColor.new("Storm blue")
            end
        end
    end
end)
0
Thanks, I'll try it out and let you know! Darkcraft10 20 — 5y
0
Everything works, thanks very much! Darkcraft10 20 — 5y
0
Your welcome, friend. namespace25 594 — 5y
Ad

Answer this question