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

My script won't work when I try to change the visibility property of a text box. Help?

Asked by 6 years ago

So when I used this script, the text box named text1 appears and stays on the screen. I can't get it to go away or show text2. Here's the script I used:

local text1 = game.StarterGui.ScreenGui.text1 local text2 = game.StarterGui.ScreenGui.text2

text1.Visible = true wait(3) text1.Visible = false wait(2) text2.Visible = true wait(3) text2.Visible = false

*Note - I'm a beginner, so I probably missed something obvious.

0
The script didn't appear on the question how I wanted it to, but you get the idea. happygirl29922 -3 — 6y
0
any errors in the output? Kyokamii 133 — 6y
0
nope happygirl29922 -3 — 6y

1 answer

Log in to vote
2
Answered by
spr_ead 47
6 years ago

StarterGui hold all the guis that'll be replicated to the player's PlayerGui. What the player sees on their screen are descendants of their PlayerGui. Instead use this script:

local player = game.Players.LocalPlayer
local pgui = player:WaitForChild('PlayerGui')
local sgui = pgui:WaitForChild('ScreenGui')

local text1 = sgui:WaitForChild('text1')
local text2 = sgui:WaitForChild('text2')

text1.Visible = true
wait(3)
text1.Visible = false
wait(2)
text2.Visible = true
wait(3)
text2.Visible = false

Also, to make your code look better, please use a codeblock. If this was helpful, please accept this answer.

0
Thank you soooo much!!! happygirl29922 -3 — 6y
0
If this helped you, please accept this answer, there's an Accept Answer button below this answer spr_ead 47 — 6y
Ad

Answer this question