I am trying to make a screen gui for my nuclear reactor that says the core status... it wont work?!?
heres the screen gui text changer script:
1 | while true do |
2 | script.Parent.TextBox.Text = "Core Status : " .. game.Workspace.GuiValue |
3 | wait(. 1 ) |
4 | end |
heres the core temp monitor and value changer script:
01 | while true do |
02 | if game.Workspace.Temp.Current.Value > - 276 then |
03 | game.Workspace.GuiValue.Value = "Core too cold!" |
04 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. b = 255 |
05 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. g = 0 |
06 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. r = 0 |
07 | end |
08 | end |
09 |
10 | while true do |
11 | if game.Workspace.Temp.Current.Value > 0 then |
12 | game.Workspace.GuiValue.Value = "Core stable" |
13 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. b = 0 |
14 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. g = 255 |
15 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. r = 0 |
This may be the dumbest script EVER, i dont know, i am bad at scripting, please help!
while
loops are yuck. Read about the Changed event. Making changes to the StarterGui
won't be seen until after the player respawns and all of the ScreenGuis
are loaded into their PlayerGui
again. Another thing is what Tesouro said- r, g, and b are read only values. You have to reset the whole color using Color3.new
. I'll re-write your script to show you how I would do it.
"screen gui and text changer script," you don't need the other one now.
01 | local curTemp = Workspace.Temp.Current |
02 | local msg = script.Parent.TextBox -- I'd consider changing this to a TextLabel if you don't want people to be able to edit it in-game |
03 |
04 | curTemp.Changed:connect( function (temp) |
05 | if temp < = - 276 then -- I think this is what you were getting at :) |
06 | msg.Text = "Core too cold!" |
07 | msg.BackgroundColor 3 = Color 3. new( 0 , 0 , 1 ) -- parameters for Color3.new go between 0 and 1 |
08 | elseif temp > - 276 and temp < 276 then |
09 | msg.Text = "Core stable" |
10 | msg.BackgroundColor 3 = Color 3. new( 0 , 1 , 0 ) |
11 | elseif temp > = 276 then |
12 | msg.Text = "Core overheat!" |
13 | msg.BackgroundColor 3 = Color 3. new( 1 , 0 , 0 ) |
14 | end |
15 | end ) |
BackgroundColor3.r
or g
or b
are read-only properties, you can't change them like that. Have a look at this and this.
Also, you placed a lot of while true do
loops and all without wait
, that is wrong.
And in the second line of the first script you forgot the .Value
in the end.
It may look like this:
01 | while true do |
02 | if game.Workspace.Temp.Current.Value > - 276 then |
03 | game.Workspace.GuiValue.Value = "Core too cold!" |
04 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. b = 255 |
05 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. g = 0 |
06 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. r = 0 |
07 | end |
08 | if game.Workspace.Temp.Current.Value > 0 then |
09 | game.Workspace.GuiValue.Value = "Core stable" |
10 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. b = 0 |
11 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. g = 255 |
12 | game.StarterGui.CoreStatusGui.TextBox.BackgroundColor 3. r = 0 |
13 | end |
14 | if game.Workspace.Temp.Current.Value > 0 then |
15 | game.Workspace.GuiValue.Value = "Core Overheat!" |