Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The TextLabel wont work in this game! Any help?

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)

4 comments

0

i need help with this too

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

0

I strongly disagree. I have done so with a normal script and am using it for another game.

1

you might disagree but Vulkarin is correct

1 answer

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.

2 comments

0

And I have no clue why the Lua code editor did that...

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.