All I need is a script that turns off the lights every 30 seconds and the player will have to turn them on manually via the proximityprompt. Player will have only 15 seconds to do it. So if he doesn't turn them on, he will die. And immediately the script resets so it will have 30 seconds again to check the cameras and watch the monster that moves there. And like this all the time. I already have a teleporting monster and cameras but i am not scripter so i cant do this script... :( Please someone help me... I will be very happy!
Thank you for helping. Rohlik1234567890
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 -- You can configure how many seconds need to pass to turn off the light 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 -- We set a variable so we can count how many seconds passed repeat -- We repeat until 30 seconds is up if Light.Enabled == false then -- If the light is already turned off return so it won't turn off randomly after turning on return end i = i + 0.1 task.wait(0.1) -- task.wait is guaranteed to run the next frame unlike normal wait 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