Hello there. thanks for opening this post!
The script below has an argument called “FLICKER”
the code below is supposed to make the light flicker different from a duplicate of it by chosing a random value with small offset by dividing.
For some reason the output is always the same and not random.
Help is apprecianted. Code Examples Recommended
local db = true
function Toggle()
if db then db = false
local DefaultFlickers = 20 -- Adjustable offset value
local MinFlickers = 15 -- Original minimum value
local MaxFlickers = 25 -- Original maximum value
-- Generate a random amount between MinFlickers and MaxFlickers
local randomValue = math.random(MinFlickers, MaxFlickers)
-- Add the DefaultFlickers directly
local Amount_For_Flickers = randomValue + DefaultFlickers
print(Amount_For_Flickers) -- Output the result for testing
-- Apply the offset after generating the random value
warn(Amount_For_Flickers)
for i = 1, Amount_For_Flickers do
script.FLICKER_SOUND.Value.PlaybackSpeed = math.random(80,120) / 100
script.FLICKER_SOUND.Value:Play()
script.ACTUAL_LIGHT.Value.Enabled = false
for a,b in ipairs(script.LIGHT_ONE.Value:GetDescendants()) do
b.Material = Enum.Material.Glass
end
local DefaultBlinkDelay = script.FLICK_DELAY.Value -- NUMBERVALUE!
local MinBlinkDelay = DefaultBlinkDelay / 1.5
local MaxBlinkDelay = DefaultBlinkDelay * 1.5
-- Seed the random number generator with a more dynamic seed
math.randomseed(os.time() + tick() * 1000) -- Using tick() to add more variability
-- Generate a random floating-point value between MinBlinkDelay and MaxBlinkDelay
local randomValue = MinBlinkDelay + (math.random() * (MaxBlinkDelay - MinBlinkDelay))
-- Add the DefaultBlinkDelay directly
local BlinkWaitTime = randomValue + DefaultBlinkDelay
task.wait(BlinkWaitTime)
script.ACTUAL_LIGHT.Value.Enabled = true
for a,b in ipairs(script.LIGHT_ONE.Value:GetDescendants()) do
b.Material = Enum.Material.Neon
end
task.wait(script.FLICK_DELAY.Value)
end
end
db = true
end
script.FLICKER_EVENT.Value.Event:Connect(Toggle)