#Flicker script

10 messages · Page 1 of 1 (latest)

wise hound
#

Original script:

all time is in seconds, if you need anything then send me a PM!]]--



local Min = 6 -- Flicker intensity (The lower the number, the darker the minimum)
local Max = 18 -- Flicker intensity (The higher the number, the brighter the maximum)
local TMin = 1 -- Minimum time between flashes (In Seconds)
local TMax = 5 -- Maximum time between flashes (In Seconds)
local Normal = 25 -- Range of the light when it's not flickering
local W = 0.1 -- The amount of time between flashes, in the flash sequence

------------------------------------SCRIPT--------------------------------------------------


local L = script.Parent -- What "Light" means
print ("Flicker Script Loaded")

while true do -- Da Loop
    wait (math.random(TMin, TMax)) -- Wait a random amount of time between the Min and Max. Changeable (Min, Max)
    print ("Running")
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = math.random(Min, Max)
    wait (W)
    L.Range = Normal
end

-- Made by AlgyLacey```
#

My script:

#
all time is in seconds, if you need anything then send me a PM!]]--


local function lightbulb()
local Min = 6 -- Flicker intensity (The lower the number, the darker the minimum)
local Max = 18 -- Flicker intensity (The higher the number, the brighter the maximum)
local TMin = 2 -- Minimum time between flashes (In Seconds)
local TMax = 30 -- Maximum time between flashes (In Seconds)
local Normal = 60 -- Range of the light when it's not flickering
local W = 0.1 -- The amount of time between flashes, in the flash sequence

------------------------------------SCRIPT--------------------------------------------------


local Flicker = script.Parent -- What "Light" means
print ("Flicker Script Loaded")

while true do -- Da Loop
    task.wait (math.random(TMin, TMax)) -- Wait a random amount of time between the Min and Max. Changeable (Min, Max)
    print ("Running")
    
    Flicker.Range = math.random(Min, Max)
    print("Flickered once")
    local chance = 100*(1-0.1)^time()
    print("Began Tracking time:" + time(Flicker))
    while chance >= 70 do
        Flicker.Range = math.random(Min, Max)
        task.wait(W)
        Flicker.Range = math.random(Min, Max)
        task.wait(W)
        Flicker.Range = math.random(Min, Max)
        task.wait(W)
        Flicker.Range = math.random(Min, Max)
    end
    while chance < 70 and chance >= 30 do
        Flicker.Range = math.random(Min, Max)
        task.wait(W*2)
        Flicker.Range = math.random(Min, Max)
    end
    while chance < 30 and chance >=5 do
        Flicker.Range = math.random(Min, Max)
        task.wait(W*3)
        Flicker.Range = math.random(Min, Max)
    end
    wait (W)
    Flicker.Range = math.random(Min, Max)
    wait (W)
    Flicker.Range = math.random(Min, Max)
    wait (W)
    Flicker.Range = math.random(Min, Max)
    wait (W)
    Flicker.Range = Normal
end```
#

What i'm trying to do is have the script flicker randomly, with a maximum of 30 seconds between each 'flicker attack', but also have a random amount of time between the flickers themselves AND a random amount of flickers in each 'chance' range.

#

I'm assuming i'd need a function to have the random amount of flickers in each 'chance' range without making the code entirely unreadable, but i think i can do the random waits by just getting rid of the W variable and using math.random (0.1, 3) or smth

#

or ig i could set w = math.random(0.1,3) now that i think of it

wise hound
#

New version

vernal galeBOT
#

studio** You are now Level 2! **studio

wise hound
#
local Min = 6 -- Flicker intensity (The lower the number, the darker the minimum)
local Max = 18 -- Flicker intensity (The higher the number, the brighter the maximum)
local TMin = 2 -- Minimum time between flashes (In Seconds)
local TMax = 3 -- Maximum time between flashes (In Seconds)
local Normal = 60 -- Range of the light when it's not flickering
local W = math.random(0.1,0.3) -- The amount of time between flashes, in the flash sequence

#
local Flicker = script.Parent -- What "Light" means
print ("Flicker Script Loaded")

while true do -- Da Loop
    task.wait(math.random(TMin, TMax))
    repeat -- Wait a random amount of time between the Min and Max. Changeable (Min, Max)
        print ("Running")
        for i = 0, 20, 1 do
            chance = 100*(1-0.1)^i 
            print(chance)
            print("Began Tracking power: "..tostring(chance).."" )
            
            repeat
                Flicker.Range = math.random(Min, Max)
                task.wait(W)
                chance = 100*(1-0.1)^i
                wait(1)
            until chance < 70
            print("Flicker phase 1 complete")
            
            while chance < 70 do
                repeat
                Flicker.Range = math.random(Min, Max)
                task.wait(W*2)
                    chance = 100*(1-0.1)^i
                    wait(1)
            until chance < 30
                print("Flicker phase 2 complete")
                end
            
            while chance < 30 do
                repeat
                Flicker.Range = math.random(Min, Max)
                task.wait(W*3)
                    chance = 100*(1-0.1)^i
                    wait(1)
            until chance <= 5
            print("Flicker phase 3 complete")
            end
            
            task.wait (W)
            Flicker.Range = Normal
        end
    until Flicker.Range == Normal
    print("Ended flicker sequence")
end```