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

How do you add 1 to an existing number in a textbox?

I am making a click to earn game, like make it rain. I have a textbox that starts out as "0 Pickles", and when they click the imagebutton, (a pickle) it increases the number in the textbox by one. Here is some code I tried below.

Pickles = script.Parent.Parent.Pickles

function onClick()
Pickles.Text = " +1 Pickles"
end

script.Parent.MouseButton1Click:connect(onClick)

1 answer

✓ Accepted answer

You need to have an independent value for the function to refer to.

Try something like this :

Pickles = script.Parent.Parent.Pickles
N = 0

script.Parent.MouseButton1Click:connect(function()
	N = N + 1
	Pickles.Text = N .. " Pickles"
end)

-- N works as a counter each time you click

I hope this helped!

TheArmoredReaper

5 comments

0

Thank you! (P.S you forgot the ) after end :)

0

I need something that makes the "Pickles Per Second" count go up one, but it will take away 50 pickles.

0

do you mean When it reaches 50 it will subtract 50?

0

Like an upgrade to the PpS?

0

Yes, an upgrade, I made a new question, its almost solved, but if you could help the answer that almost worked that would help!

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