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

Why PointLight dont enable?

i want to make a alarm what will enable when is the core melting or freezeing. But it dont enables.

while true do
temp = game.Workspace.Temp.Value
if temp == 3000 then
script.Parent.PointLight.Enabled = true
elseif temp == 2700 then
script.Parent.PointLight.Enabled = false
elseif temp == 2200 then
script.Parent.PointLight.Enabled = false
elseif temp == -100 then
script.Parent.PointLight.Enabled = false
elseif temp == -300 then
script.Parent.PointLight.Enabled = false
else
script.Parent.PointLight.Enabled = true
end
wait()
end

1 answer

The reason for this is probably that you are only checking if the value is equivalent to a number, rather than seeing if it is lesser than / greater than that number, which leaves a number like 3001 or 0 to turn the point light on.

A couple of other things it would be great to do would be :

  • Properly indent your code

  • Use local variables if they aren't used outside of their scope

  • Try to find alternatives to using an infinite loop

I don't really know what you are trying to do with your light as you weren't really descriptive in your question, so here is my best estimate of what you were trying to do:

while true do
	local temp = workspace.Temp.Value
	local light  = script.Parent.Pointlight
	If temp >= 3000 or temp <= -300 then
		light.Enabled = true
	else
		light.Enabled = false
	end
	wait()
end

1 comment

0

Its not working :C

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