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

Why isn't TextBox a valid member of my surface gui script?

I am trying to make a script that will change the values of TextColor3 in a textbox. but I keep getting an error that says "TextBox is not a valid member."

local textbox = game.Workspace.info.Color.TextBox

while true do 
	textbox.TextColor3 = 255,0,0
	wait(0.5)
	textbox.TextColor3 = 0,255,238
	wait(0.5)
	textbox.TextColor3 = 40,255,3
	wait(0.5)
	textbox.TextColor3 = 251,131,255
	wait(0.5)
end

1 comment

2

Try textbox = game.Workspace:WaitForChild("info"):WaitForChild("Color"):WaitForChild("TextBox")

1 answer

You need to define textbox. Look at this example-

local textBox = Instance.new("TextLabel") -- textBox is not a defined part of workspace, it is more of a allowance, So instead of defining Text Box as apart in workspace, the server automatically makes the textbox appear.
textbox.Parent = screen -- screen is also not a clear defined parent So you would need to define screen also :)
textBox.Text = "Welcome to the City of bloxbury"
textBox.Size = UDim2.new(1,0,1,0)
textBox.FontSize = Enum.FontSize.Size14
textBox.Font = Enum.Font.SourceSansLight -- etc.

Also a good note to remember, TextBoxes, TextLabels, and ImageLabels are all GUIs, When you want to define a GUI, you never define in the workspace. Workspace is for 3D objects to be appeared in as Parts.

I hoped I helped, Sammy

PS- look at http://wiki.roblox.com/index.php?title=Beginner%27s_GUI_Tutorial

  • this will help you learn a more defined remark of GUIs :)

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