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

My code wont update my GUI, and wont print what im telling it to print in Console. Why?

its really frustrating. My code is:

moneyGUI = 0
moneyINC = 1
moneyGUIaboveTwenty = 0
while true do

	moneyGUI = moneyGUI + moneyINC

	if game.StarterGui.ScreenGui.TextButtonPlus.Activated then
			moneyINC = moneyINC + 1
	end

	if game.StarterGui.ScreenGui.TextButtonMinus.Activated then
			moneyINC = moneyINC - 1
	end
	if moneyINC < 0 then
		moneyINC = 0
	end

	game.StarterGui.ScreenGui.Money.Text = ("$ ") + moneyGUI

	
	

	print(moneyGUI)

	wait(0.5)
	

1 comment

0

By the way i have end at the end of my script i just forgot to copy-paste it.

1 answer

I don't know the technical terms for it, but when you want to combine something like a string and a variable you'd do something like this: "String" .. variable What you tried to do in your code is perform addition on a word and a number, which you can't do.

So for your code, you'd do

moneyGUI = 0
moneyINC = 1
moneyGUIaboveTwenty = 0
while true do

    moneyGUI = moneyGUI + moneyINC

    if game.StarterGui.ScreenGui.TextButtonPlus.Activated then
        moneyINC = moneyINC + 1
    end
    if game.StarterGui.ScreenGui.TextButtonMinus.Activated then
       moneyINC = moneyINC - 1
    end
    if moneyINC < 0 then
        moneyINC = 0
    end

    game.StarterGui.ScreenGui.Money.Text = "$ ".. moneyGUI

    print(moneyGUI)

    wait(0.5)
end

1 comment

0

Thanks! That helped a bunch.

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