Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to combine these two scripts?

while true do
    if game.Lighting.Brightness >= 0.9 or game.Lighting.Brightness <= 0 then
		script.Parent.SpotLight.Enabled = true
    else
		script.Parent.SpotLight.Enabled = false
    end
    wait()
end
while true do
    local minutes = game.Lighting:GetMinutesAfterMidnight()
    if minutes >= 1020 or minutes <= 480 then
		script.Parent.SpotLight.Enabled = true
    else
		script.Parent.SpotLight.Enabled = false
    end
    wait()
end

So these lights turn on when brightness is 0 "a storm is going by" or the time is at night. The problem these being two scripts, during day with brightness 0 the lights flicker because the scripts are fighting each other. How could these scripts be combined so if one is true then the lights will turn on even if the other is false?

2 answers

I'm not entirely sure what you're trying to do so sorry if this is of no help but.. I think..?

local spotlight = script.Parent.SpotLight
local lighting = game.Lighting

while wait() do
	local minutes = game.Lighting:GetMinutesAfterMidnight()
	if lighting.Brightness >= 0.9 or lighting.Brightness <= 0 or minutes >= 1020 or minutes <= 480 then
		script.Parent.SpotLight.Enabled = true
	else
		script.Parent.SpotLight.Enabled = false
	end
end

1 comment

1

well I figured it out myself, I gave you too many errors to work with in the first place, thank you for getting me where I needed to get

while true do
    local minutes = game.Lighting:GetMinutesAfterMidnight()
    if minutes >= 1020 or minutes <= 480 or game.Lighting.Brightness <= 0.5 then
		script.Parent.SpotLight.Enabled = true
    else
		script.Parent.SpotLight.Enabled = false
    end
    wait()
end

that's how it was supposed to be set up

This discussion is preserved as it was. New answers, comments, and votes are closed.