✓ Accepted answer
First, you will need lamp models, inside the models you will need a light instance, if you set it up according to my script it will be easier, make a model then make an Attachment (Or anything else that holds the light instance) named "LightHolder", then put SpotLight or any light source in it, also if you want a switch with it make a switch model then name the clickable part "SwitchPart" then put a ClickDetector inside it, group the switch model and the light model together and name them "LightModel" and "SwitchModel" then put it in a Folder named "Lights" in the workspace, the script (Edited my answer because there was something wrong):
local Lights = workspace:WaitForChild("Lights")
local WaitTime = 30
for _,LightGroup in pairs(Lights:GetChildren()) do
local Light = LightGroup.LightModel.LightHolder.Light
local Detector = LightGroup.SwitchModel.SwitchPart.ClickDetector
Detector.MouseClick:Connect(function()
if Light.Enabled then
Light.Enabled = false
else
Light.Enabled = true
local i = 0
repeat
if Light.Enabled == false then
return
end
i = i + 0.1
task.wait(0.1)
until i >= WaitTime
Light.Enabled = false
end
end)
if Light.Enabled then
local i = 0
repeat
if Light.Enabled == false then
return
end
i = i + 0.1
task.wait(0.1)
until i >= WaitTime
Light.Enabled = false
end
end
1 comment
Damn and what is with assuming the players gender lol