Light system not working

This light turns on at a certain temperature

my script keeps on getting an error

if workspace.CoreContnroleRoom.Temp.Value >= 4200 then
	script.light.Enabled = true 
	end
1 Like

What did the error say at the moment?

1 Like

RobloxStudioBeta_qfxigGT7h9

1 Like

The reason is because there’s no light inside the script, just give the correct path and it should work.

if the script and light is in the same parent then try:
script.Parent.light

I changed the script
image

RobloxStudioBeta_IG0zJCItRP

You could just move the light into the MeshPart.

1 Like

I found my problem but don’t know how to fix it. temp value has to be 4200 put before I play the game but if I make it 4200 in the game it will not work how do I fix that

You should use a loop to keep checking it.

1 Like

I wouldn’t use a loop, just use the .changed event.
so something like

workspace.CoreControleRoom.Temp.Changed:Connect(function(v)
   if v >= 4200 then
      script.Parent.light.Enabled = true
   else
      script.Parent.light.Enabled = false
   end
end)

Basically intvalues (which is what I’m assuming Temp is) have a .Changed event, which fires whenever the value changes. What you can do is connect this function to that which will cause this function to run every time the value changes. Then it just checks to see if the temperature is high enough and boom, it turns the light off or on.

1 Like