My goal is to have this print out a message in a gui and this is code from my main game script so it can end up guiding the game but I need a place to keep the players informed on how my game works and how long each round has. Line 5 has the place the nil error is:
01 | local display |
02 | game.Workspace:FindFirstChild( "valueHold" , display) |
03 |
04 | wait ( 10 ) |
05 | display.Value = "Welcome to Game. thanks for joining" |
06 | print "Initial Message was set" |
07 | --wait(10) |
08 | --display.Value = "Game still being developed, stay tuned" |
09 | --print "Secondary message set" |
10 |
11 | local display = script.Parent |
12 | local messa |
13 | game.Workspace:FindFirstChild( "StringValue" , messa) |
14 | local messageToDisplay = messa.Value |
15 |
Thank you for the help! P.S. I know the code is a little messy, but I'm learning and it's in the works :)
You defined the value after getting it. Therefore, it is nil
. To fix this, just change line 1 to:
1 | local display = script.Parent |
instead.
Also, remove line 11, we don't need it because it is already defined.
By the way, are the hyphens on line 7 to 9 intentional?
Hope this helps!
Don't forget to accept this answer if it does!