I've written 3 different scripts; 2 of which are working. I seperated them because of some issues I was having with the onTouched function and it repeating and whatnot. Anyways, that's not the point; My third script compiles, and prints the success message into the outbox, but isn't really doing it's job. Here it is.
01 | local f = true |
02 | script.Parent.Touched:connect( function () |
03 | game.StarterGui:WaitForChild( "TalkingGui" ) |
04 | if f = = true |
05 | then |
06 | f = false |
07 | wait( 10 ) |
08 | game.StarterGui.TalkingGui.TextLabel.Text = "Woah...W-What in the world was that?" |
09 | wait( 3 ) |
10 | game.StarterGui.TalkingGui.TextLabel.Text = "Maybe I should get out of here..." |
11 | wait( 3 ) |
12 | game.StarterGui.TalkingGui.TextLabel.Text = " " |
13 | print ( "Talking successful!" ) |
14 | wait( 10 ) |
15 | f = true |
16 | end |
17 | end ) |
Ahh, I see your issue. It is doing its job that you assigned it, which is changing a GUI's text located in StarterGui. For it to change the player's GUI, you have to go inside the PlayerGui. The following solution is assuming this game isn't FilteringEnabled:
01 | local f = false -- just so it won't confuse me |
02 | script.Parent.Touched:connect( function (hit) |
03 | if game.Players:GetPlayerFromCharacter(hit.Parent) and f = = false then -- Checks if it's a player. You can look |
04 | on the wiki for a little more explanation |
05 | local f = true |
06 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
07 | wait( 10 ) |
08 | plr.PlayerGui.TalkingGui.TextLabel.Text = "Woah...W-What in the world was that?" |
09 | wait( 3 ) |
10 | plr.PlayerGui.TalkingGui.TextLabel.Text = "Maybe I should get out of here..." |
11 | wait( 3 ) |
12 | plr.PlayerGui.TalkingGui.TextLabel.Text = "" |
13 | print ( "Talking Successful!" ) |
14 | wait( 10 ) |
15 | f = false |
16 | end |
17 | end ) |
Any questions? Be sure to comment!