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

Add an amount to a number value?

Asked by 7 years ago

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)
0
There was no errors I could find in F9 iiCoulroPhobia 10 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

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
Ad
Log in to vote
0
Answered by
jotslo 273 Moderation Voter
7 years ago

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.

Answer this question