Hey! So I am really confused on how to make a streetlight script. The old Roblox one just won’t work for me and I can’t find any tutorials that work! Does anyone have any code for this that they know works in 2020?
PS: I do not want a Day/Night cycle included in the script
Uh I mean, there’s a billion ways to make one depending on how you want it to work. If you just want the script to change the light from green to yellow and then red, just make a While true do script which will wait() a certain amount of time, then turn the light to yellow (probably by setting its material), then repeat it again twice for red and back to green.
Oh I thought you meant a traffic light. If you don’t want a day/night cycle, how do you want it to work? If you just want it to turn on and off repeatedly, make a while true do loop that cycles between setting the light’s material and color to one which appears to be glowing, and then doing the opposite. Use a wait() between each one.
Yeah not a traffic light bahaha. See the video I linked. I want to make it so if ClockTime is past 18 and before 6 then make the pointlight enabled, otherwise turn it off. Nothing I’ve tried has worked, any suggestions?
local lamps = --where your lamps are stored
game.Lighting.Changed:Connect(function()
local var = game.Lighting.ClockTime < 6 or game.Lighting.ClockTime > 18
for i,v in pairs(lamps:GetDescenants()) do
if v:IsA("Light") then
v.Enabled = var
end
end
end)
local lightPart = script.Parent
local PointLight = lightPart.PointLight
while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() > 6*60 then
lightPart.Material = Enum.Material.Plastic
PointLight.Enabled = false
end
if game.Lighting:GetMinutesAfterMidnight() > 18*60 then
lightPart.Material = Enum.Material.Neon
PointLight.Enabled = true
end
end
Nope, I think it’s outdated. No errors, no mistakes, no nothing. It just turns off the light and sets the material to plastic but won’t ever change to neon or enable anything no matter the time.