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

How do I make it if a player puts a certain text in a text box it makes a text label visible?

Asked by 4 years ago

Code:

01local textBox = script.Parent
02 
03local secretWord = "Testing1"
04local colorNormal = Color3.new(1, 1, 1) -- white
05local colorWrong = Color3.new(1, 0, 0) -- red
06local colorCorrect = Color3.new(0, 1, 0) -- green
07 
08textBox.ClearTextOnFocus = true
09textBox.Text = ""
10textBox.Font = Enum.Font.Code
11textBox.PlaceholderText = "Write the text here"
12textBox.BackgroundColor3 = colorNormal
13 
14local function onFocused()
15    textBox.BackgroundColor3 = colorNormal
View all 41 lines...

How the gui is placed: https://i.gyazo.com/b69941e3a9e752aa47b71c2a0c65e874.png

0
Any errors? ThatDevTim 188 — 4y
0
14:17:16.461 - TextLabel is not a valid member of Frame 14:17:16.463 - Stack Begin 14:17:16.465 - Script 'Players.DevSeveral.PlayerGui.ScreenGui.Frame.Chatbox.LocalScript', Line 23 - function onFocusLost 14:17:16.466 - Stack End DevSeveral 19 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Your error is in line 24, like the error message says. You are doing 1 too many ".parent"s. ".Parent" Goes to the TextBox, and another ".Parent" goes to the frame.

New Code Line 24

1script.Parent.TextLabel.Visible = true

All Code

01local textBox = script.Parent
02 
03local secretWord = "Testing1"
04local colorNormal = Color3.new(1, 1, 1) -- white
05local colorWrong = Color3.new(1, 0, 0) -- red
06local colorCorrect = Color3.new(0, 1, 0) -- green
07 
08textBox.ClearTextOnFocus = true
09textBox.Text = ""
10textBox.Font = Enum.Font.Code
11textBox.PlaceholderText = "Write the text here"
12textBox.BackgroundColor3 = colorNormal
13 
14local function onFocused()
15    textBox.BackgroundColor3 = colorNormal
View all 41 lines...
0
There was some confusion so I added the full code. ThatDevTim 188 — 4y
Ad

Answer this question