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

Have a chance in a "while true do" without repeating the chance?

Asked by 2 years ago

The chance keeps repeating and the northern lights show up when it hits one and when Is it possible that every night it does the random chance and only 1 number and not repeat itselfs?

local Time = 00.1
local TimeChange = 1 -- Set high for testing
local Lighting = game:GetService("Lighting")
local NorthernLights = workspace.Nature.Northerlights.NorthernlightStart

while wait(Time) do
    game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange
    if Lighting.ClockTime >= 20 then
        local Chance = math.random(1,10)
        warn(Chance)
        if Chance == 1 then
            NorthernLights.Beam.Enabled = true
            NorthernLights.Beam1.Enabled = true
            NorthernLights.Beam2.Enabled = true
            NorthernLights.Beam3.Enabled = true
        end
    elseif Lighting.ClockTime >= 4 then
        NorthernLights.Beam.Enabled = false
        NorthernLights.Beam1.Enabled = false
        NorthernLights.Beam2.Enabled = false
        NorthernLights.Beam3.Enabled = false
    end
end

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

Try to add math.randomseed(os.time()) on the first line, other than that you might try to use another number on 11th line because to my knowledge low numbers come more than high numbers.

0
I am not sure how to implement randomseed. loganmatt3 10 — 2y
0
You just need to put it on the first line, there is no implementation needed to do. enes223 327 — 2y
0
did you try using the break function? ghostbettert 30 — 2y
Ad

Answer this question