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

Problem with scripting a series of flashing lights. Any help please?

Asked by 6 years ago

I am a newbie at scripting and acquire serious help. My friend wants me to script him a series of flashing lights(Parts that change material one at a time which will conclude a series of flashing lights after night time arrives and the time needed to change material is at least 1 second). Everything went accordingly to my script(which is showcased below) until the neon parts began slowing down and then randomly started flashing around without being in sync. Any help please?

local lightPart = script.Parent

while true do
    wait(1)
    if game.Lighting:GetMinutesAfterMidnight() > 6 * 60 then``
        ``lightPart.Material = Enum.Material.Plastic``
    end
    if game.Lighting:GetMinutesAfterMidnight() > 18 * 60 then
        lightPart.Material = Enum.Material.Neon
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Neon
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Neon
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
        lightPart.Material = Enum.Material.Neon
        wait(1)
        lightPart.Material = Enum.Material.Plastic
        wait(1)
    end
end

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago
Edited 6 years ago

Edit: I have changed the script below because the problem is that the lights flash at irregular intervals, from what I can see.

Try this:

local debounce = false

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
    if debounce == true then return end
    if game.Lighting.ClockTime > 18 then
        debounce = true
        repeat
            lightPart.Material = Enum.Material.Neon
            wait(1)
            lightPart.Material = Enum.Material.Plastic
            wait(1)
        until game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime < 6.01
        debounce = false
    end
end)
0
Nope. Just attempted this right now and it still slows down and manages to randomly flash. coolboy90082 -1 — 6y
0
Change "wait(3)" on line 11 to wait(1). I put "3" there as that is what your initial script would have done, but if the problem is that it flashes randomly, then, if you look at the script, it actually changes the material to plastic (non-lit) 3 times in a row, and the pattern is a little irregular. I have edited my script above. UgOsMiLy 1074 — 6y
Ad

Answer this question