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

The TextLabel wont work in this game! Any help?

Asked by 6 years ago

So I was remaking a Coinflip for a Clicker game into just a normal game! But it wont update the bux!

local remotes = game.ReplicatedStorage

remotes.Coinflip.OnServerEvent:Connect(function(plr,bet,result)
    local bux = game.StarterGui.GameGUI.bux.buxAmount.Value
    if bux >= bet and bux > 0 then
        if result == "win" then
            bux = bux + bet;
            game.StarterGui.GameGUI.bux.Visible = false
            game.StarterGui.GameGUI.bux.Text = bux
            game.StarterGui.GameGUI.bux.buxAmount.Value = bux
            wait(0.05)
            game.StarterGui.GameGUI.bux.Visible = true
            print(plr.Name .. " JUST WON!")
        else
            bux = bux - bet;
            game.StarterGui.GameGUI.bux.Visible = false
            game.StarterGui.GameGUI.bux.Text = bux
            game.StarterGui.GameGUI.bux.buxAmount.Value = bux
            wait(0.05)
            game.StarterGui.GameGUI.bux.Visible = true
            print(plr.Name .. " JUST LOST!")
        end
    end
end)
0
i need help with this too magentacrasyguy -7 — 6y
2
You're changing the startergui, that won't affect anything other than the GUI player's spawn with...you will only be capable of changing a player's GUI via a localscript Vulkarin 581 — 6y
0
I strongly disagree. I have done so with a normal script and am using it for another game. SGYTMinersHaven -16 — 6y
1
you might disagree but Vulkarin is correct GingeyLol 338 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
remotes = game.ReplicatedStorage

remotes.Coinflip.OnServerEvent:Connect(function(plr,bet,result)
    local bux = game.StarterGui.GameGUI.bux.buxAmount.Value
    if bux >= bet and bux > 0 then
        if result == "win" then
            bux = bux + bet;
            game.StarterGui.GameGUI.bux.Visible = false
            for _,p in pairs(game.Players:GetPlayers()) do
                p.PlayerGui.GameGUI.bux.Text = bux
        end
            game.StarterGui.GameGUI.bux.buxAmount.Value = bux
            wait(0.05)
            game.StarterGui.GameGUI.bux.Visible = true
            print(plr.Name .. " JUST WON!")
        else
            bux = bux - bet;
            game.StarterGui.GameGUI.bux.Visible = false
            for _,p in pairs(game.Players:GetPlayers()) do
        p.PlayerGui.GameGUI.bux.Text = bux
        end
            game.StarterGui.GameGUI.bux.buxAmount.Value = bux
            wait(0.05)
            game.StarterGui.GameGUI.bux.Visible = true
            print(plr.Name .. " JUST LOST!")
        end
    end
end)

Two errors here:

  • Pay attention to lines 7 and 8 and lines 17 and 18. These modify the PlayerGui.

  • Local variables will not work, use regular variables. I still don't understand why people keep using them; they are meant for their native code block.

0
And I have no clue why the Lua code editor did that... DeceptiveCaster 3761 — 6y
0
Well, if you're doing stuff like "if number1 == number3 - number 2" then it wont work. You need to make another variable. Also, like what MCAndRobloxUnited said, you need to make then a normal variable. Mr_Unlucky 1085 — 6y
Ad

Answer this question