So, I’m making a system that when you click on a button it makes a Spotlight brightness go higher until it reach the value of 0.4 then if you click again it make the brightness go darker until it reach 0
But it doesn’t work at all and doesn’t trow any error, so I can’t fix it
I’m pretty sure the error come from these two code block
while Light.Brightness > 0.4 do
Light.Brightness = Light.Brightness + 0.01
wait(0.01)
end
-------------------------------------------------------------
while Light.Brightness < 0 do
Light.Brightness = Light.Brightness - 0.01
wait(0.01)
end
Anyway, code is below:
local Model = script.Parent
local Button = Model.Button.ClickDetector
local LightModel = Model.Model
local LightPart = LightModel.Light
local Light = LightModel.Light.SpotLight
local Value = Model.IsOn.Value
Button.MouseClick:Connect(function()
if Value == false then
LightPart.Material = Enum.Material.Neon
while Light.Brightness > 0.4 do
Light.Brightness = Light.Brightness + 0.01
wait(0.01)
end
Value = true
else
while Light.Brightness < 0 do
Light.Brightness = Light.Brightness - 0.01
wait(0.01)
end
Value = false
LightPart.Material = Enum.Material.SmoothPlastic
end
end)
Some screenshot if neede:
Any help is really appreciated right now.