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

Add an amount to a number value?

I'm having trouble adding an amount to my numbervalue if another numbervalue == 1.

v = script.Parent

function onclick()
	if script.Parent.Parent.Parent.Parent.StarterGui.ScreenGui.ALL1.Correct.Value == 1 then
		v.Value = (v.Value + 20)
		print ("Added 20!")
	end
end

script.Parent.Parent.Parent.Parent.StarterGui.ScreenGui.SUBMIT.TextButton.MouseButton1Click(onclick)

2 comments

0

There was no errors I could find in F9

2 answers

You were targeting startergui instead of playergui you might understand with the right version of the script

function onclick()
    if script.Parent.ALL1.Correct.Value == 1 then
        v.Value = (v.Value + 20)
        print ("Added 20!")
    end
end

script.Parent.SUBMIT.TextButton.MouseButton1Click(onclick) --you can also use MouseButton1Down

StarterGui is a bin. Everything in it will be copied over to a folder called "PlayerGui" which is located in each player currently in the server. I have written more about it here if you want to find out more.

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