Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to combine these two scripts?

Asked by 10 years ago
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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

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
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 alerttrains123 10 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
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

Answer this question