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

Why doesn't my script change my TextLabel's text?

Asked by 5 years ago

I have tried many things. My Text Label is in a Frame inside of the StarterGui. My code looks like this:

wait(3)
game.StarterGui.ScreenGui.Frame.TextLabel.Text = "But it was me, Dio!"
end)

Can someone tell me what's wrong with it or provide a new code that I can copy an put in my game.

Thanks in advance, San

0
Are you trying to change the players Gui, or the starterGui? If its the players, then you need to use a local script inside the gui and change "game.StarterGui" to "player.PlayerGui". Stephenthefox 94 — 5y
0
or remove the wait HappyTimIsHim 652 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

Because your changing the text from the StarterGui You need to access the player gui which can only be done in a local script.

Please go to the wiki or youtube to learn more about the PlayerGui Hope this helps!

Ad
Log in to vote
0
Answered by 5 years ago

Well, first, you can only change GUI with Localscript, and second, the StarterGui is not where the player's GUI is. It acts like the StarterPack. It's just what gets put there when you spawn in, but you can't interact with it as if it was the player's.

If this is supposed to change by an event/function, read up on Remote Functions and Events. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

--this is a localscript inside of that frame.

script.Parent.TextLabel.Text = "But it was me, Dio!" --here, we affecting the player's GUI, which is in the "PlayerGui" inside the player. 

I'm sorry if this is explained weird, please leave a comment if you need more explaining.

Upvote and accept the answer if it worked

0
Good job, but an upvote won't be needed as they're for posts that are really really explanatory. I've only got one or two upvotes, it's pretty hard. But yeah, most people upvote if it has explained it to them fully and has made them understand fully. So just hope it helped him fully xD. TheOnlySmarts 233 — 5y
Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

Hello, I have found a solution to your problem.

First of all, you can not access the StarterGui through script as it gets later changed to PlayerGui as you join in game. ROBLOX just decided to do it this way, which is one of the most common mistakes in beginner scripting. Even I got frustrated, but, it's not as hard as you think.

Firstly, insert a LocalScript inside your TextLabel.

Secondly, open it up, and start typing your wait(3) function.

Thirdly, type in your script.Parent line, which is your line of code, if you don't understand, just type this.

LocalScript :

script.Parent.Text = "But it was me, Dio!" -- Also I can sense your game is a drama game? Correct me if I'm wrong xD

Okay so now that we have finished that, I get confused on why you added an end). If you're using that end) for the wait loop, remove it. If you're using it for a function of code in a function, let me know, as I'm struggling to find out why you have added an end)?

Okay, hopefully this helped, let me know if it has, thanks!


Tip : If this answer has helped you or someone else you know, let TheOnlySmarts know that he helped you successfully by pressing 'Accept Answer' below! Doing this will also give you both positive reputation!
0
why yield for 3 seconds and wait() is not a loop User#23365 30 — 5y
0
You can access startergui, just changes won't be applied. wait(3) is NOT a loop. Fake tip at the bottom green271 635 — 5y
0
Sorry I meant function not loop, classical brainfarts. TheOnlySmarts 233 — 5y
0
Also, he knows its a fake tip. And also many people write that at the bottom of their answer, so don't need to go and expose me for something that is completely fine. TheOnlySmarts 233 — 5y

Answer this question