Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script isnt working?

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:

while true do
script.Parent.TextBox.Text = "Core Status : " .. game.Workspace.GuiValue
wait(.1)
end

heres the core temp monitor and value changer script:

while true do
if game.Workspace.Temp.Current.Value > -276 then
	game.Workspace.GuiValue.Value = "Core too cold!"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 255
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 0
end
end

while true do
if game.Workspace.Temp.Current.Value > 0 then
	game.Workspace.GuiValue.Value = "Core stable"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 255
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 0
end
end

while true do
if game.Workspace.Temp.Current.Value > 0 then
	game.Workspace.GuiValue.Value = "Core Overheat!"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 255
end
end

This may be the dumbest script EVER, i dont know, i am bad at scripting, please help!

2 answers

✓ Accepted answer

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.

local curTemp = Workspace.Temp.Current
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

curTemp.Changed:connect(function(temp)
	if temp <= -276 then -- I think this is what you were getting at :)
		msg.Text = "Core too cold!"
		msg.BackgroundColor3 = Color3.new(0, 0, 1) -- parameters for Color3.new go between 0 and 1
	elseif temp > -276 and temp < 276 then
		msg.Text = "Core stable"
		msg.BackgroundColor3 = Color3.new(0, 1, 0)
	elseif temp >= 276 then
		msg.Text = "Core overheat!"
		msg.BackgroundColor3 = Color3.new(1, 0, 0)
	end
end)

1 comment

0

thank you!!! it worked!! :D

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:

while true do
if game.Workspace.Temp.Current.Value > -276 then
    game.Workspace.GuiValue.Value = "Core too cold!"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 255
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 0
end
if game.Workspace.Temp.Current.Value > 0 then
    game.Workspace.GuiValue.Value = "Core stable"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 255
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 0
end
if game.Workspace.Temp.Current.Value > 0 then
    game.Workspace.GuiValue.Value = "Core Overheat!"
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.b = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.g = 0
    game.StarterGui.CoreStatusGui.TextBox.BackgroundColor3.r = 255
end
wait() -- put some time here, you can't have infinite loops without waiting
end

This discussion is preserved as it was. New answers, comments, and votes are closed.