I know it must be due to an infinite loop, but I don't know how to fix it. The two only culprits I know it is.
while true do script.Parent.Value.Value = 1 wait(10) script.Parent.Value.Value = 2 wait(10) script.Parent.Value.Value = 3 wait(10) script.Parent.Value.Value = 4 wait(10) script.Parent.Value.Value = 5 wait(10) end
A = script.Parent.Blue:GetChildren() B = script.Parent.Red:GetChildren() change = 1 script.Parent.Value.Changed:connect(function() print(change) end) while true do if script.Parent.Value.Value == 1 then change = 1 elseif script.Parent.Value.Value == 2 then change = 0.75 elseif script.Parent.Value.Value == 3 then change = 0.5 elseif script.Parent.Value.Value == 4 then change = 0.25 elseif script.Parent.Value.Value == 5 then change = 0.15 end end while true do for i,v in pairs(A) do v.PointLight.Enabled = true v.SurfaceGui.TextLabel.BackgroundTransparency = 0 end for i,v in pairs(B) do v.PointLight.Enabled = false v.SurfaceGui.TextLabel.BackgroundTransparency = 1 end wait(change) for i,v in pairs(A) do v.PointLight.Enabled = false v.SurfaceGui.TextLabel.BackgroundTransparency = 1 end for i,v in pairs(B) do v.PointLight.Enabled = true v.SurfaceGui.TextLabel.BackgroundTransparency = 0 end wait(change) end
From lines 9-21, you have not added a delay, i suggest for the most efficient one, you use wait() perhaps between each one or after the condition.
You can do either way, which ether one you want.
A = script.Parent.Blue:GetChildren() B = script.Parent.Red:GetChildren() change = 1 script.Parent.Value.Changed:connect(function() print(change) end) while true do if script.Parent.Value.Value == 1 then change = 1 elseif script.Parent.Value.Value == 2 then change = 0.75 elseif script.Parent.Value.Value == 3 then change = 0.5 elseif script.Parent.Value.Value == 4 then change = 0.25 elseif script.Parent.Value.Value == 5 then change = 0.15 end wait() end
or
while true do if script.Parent.Value.Value == 1 then change = 1 wait() elseif script.Parent.Value.Value == 2 then change = 0.75 wait() elseif script.Parent.Value.Value == 3 then change = 0.5 wait() elseif script.Parent.Value.Value == 4 then change = 0.25 wait() elseif script.Parent.Value.Value == 5 then change = 0.15 wait() end end
Hope that helped, feel free to reply if it didn't.