Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

3 comments

0

I am not sure how to implement randomseed.

0

You just need to put it on the first line, there is no implementation needed to do.

0

did you try using the break function?

This discussion is preserved as it was. New answers, comments, and votes are closed.