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

Math.Random() isnt working for me?

n = math.random(1, 24)
print("number is" ..n)

while true do
	wait(0.01)
	if game.Lighting.ClockTime == n then
		game.ServerScriptService.Rain:Clone().Parent = game.Players.LocalPlayer.Backpack
		n = math.random(1,24)
		print("number is " ..n)
		break
	end
end

4 comments

0

It works, just check your 'ClockTime' line, does ClockTime returns whole number? . 1-24 ? I've never used ClockTime before tho

0

use "math.randomseed(tick())" at the start of your scriot and only the start

0

I notice you print n but you aren't printing ClockTime. Try printing ClockTime and I think you will see the problem.

0

Also, make n a local variable by making the first line have local n instead of n

1 answer

The problem is that for you is that math.random is based on the number you got before. Thats why IT always Will return the same Value IF its not running more then once.

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