01 | local part = workspace.Part |
02 | local spotlight = part.SpotLight |
03 | local Enabled = true |
04 |
05 | script.Parent.ClickDetector.MouseClick:connect( function () |
06 | if spotlight = = Enabled then |
07 | Enabled = false |
08 | elseif Enabled = = true then |
09 | Enabled = true |
10 |
11 | end |
12 | end ) |
if you can, explain the answer so i can learn :3
Ok, so basically spotlights have a property called .Enabled, this tells the spotlight whether the light will be on or off. It's also boolean value, which means it's property can be set to true or false. If the .Enabled property is set to true, then the light will shine, if it's set to false, then the light won't shine.
1 | local part = workspace.Part |
2 | local spotlight = part.SpotLight |
3 | local Enabled = true |
4 |
5 | script.Parent.ClickDetector.MouseClick:connect( function () |
6 | Enabled = not Enabled -- This will make Enabled false if Enabled is true, this will also make Enabled true if Enabled is false |
7 | spotlight.Enabled = Enabled |
8 | end ) |