I am trying to make a flashlight with a strobe setting but it's not working.
I want the light to turn on when the player clicks. When the player clicks again it needs to switch to strobe. When the Player clicks again it needs to set the bool value "Strobe" to false and set the spotlight's enabled property to false
When I click the light turns on and Strobe is set to true. When I click again nothing happens. When I click a third time again nothing happens. If all had gone as planned the second click would have made the light strobe and the third click would have turned it all off ready to be started over with the next click.
script.Parent.Light.SpotLight.Enabled = false
script.Parent.LightSettings.Strobe.Value = false
script.Parent.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
if script.Parent.LightSettings.Strobe.Value == false and script.Parent.Light.SpotLight.Enabled == false then
script.Parent.Light.SpotLight.Enabled = true
script.Parent.LightSettings.Strobe.Value = true
else if script.Parent.LightSettings.Strobe.Value == true and script.Parent.Light.SpotLight.Enabled == true then
while script.Parent.LightSettings.Strobe.Value ==true do
script.Parent.Light.SpotLight.Enabled = true
wait(0.2)
script.Parent.Light.SpotLight.Enabled = false
end
else if script.Parent.LightSettings.Strobe.Value == true and script.Parent.Light.SpotLight.Enabled == true then
script.Parent.LightSettings.Strobe.Value = false
script.Parent.Light.SpotLight.Enabled = false
end
end
end
end)
end)
Thanks for your help.
