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

When you click a screen... continue?

I have made a textbutton that covers all across the screen and when you click it... here is the code,

script.Parent.MouseButton1Click:connect(function()
	game.StarterGui.ScreenGui.TextBox.Text = game.StarterGui.ScreenGui.TextBox.Text + 1
end)

Since TextBox is not a value I am confused on how I change the Text of textBox to add 1 when the textbutton (that covers the whole screen) is clicked. The problem is though is that it looks like this in explorer in studio.. game>StarterGui>ScreenGui>Textbutton>Script and then game>StarterGui>ScreenGui>TextBox... Is this right or should they both be in the same screen gui? They are both in opposite screen GUIs in the StarterGui. Is this right?

2 answers

✓ Accepted answer

You can use a Variable. An Intvalue or what not is not required.

local number = 0
local sp = script.Parent
sp.MouseButton1Click:connect(function()
number = number +1
sp.Text = ""..number
end)

1 comment

0

He can use a variable, not should different methods for the same thing, however if he needs to call it from another script would a variable not be easier?

Try putting an IntValue in the Textbox then do this (Put this script in the text box too):

local Int = script.Parent.IntValue
local TextBox = script.Parent
TextBox.Text =  "" .. Int.Value
script.Parent.MouseButton1Click:connect(function()
		TextBox.Text = "" .. Int.Value +1
	end)

Try that.

2 comments

0

He should use a variable...

0

I got it to work with this script but I am made a little adjustments first.

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