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

math.random is only picking 1 map?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago
Edited 8 years ago

I'm trying to pick a map but it keeps picking the same map (I have 1 model that contains 2 maps in replicated storage)

local RS = game:GetService('ReplicatedStorage') --Same thing as saying (game.Lighting)
local Maps = RS.Maps:GetChildren()
local PickMap = math.random(1,#Maps)
local SelectedMap = Maps[PickMap]:Clone()

print(SelectedMap.Name)
SelectedMap.Parent = workspace
1
have you tried running it a ton of times? there are only 2 maps EssentialRoll 30 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago
Edited 8 years ago

This most likely isn't a bug but is caused by you not changing the seed of the random generator, at the beginning of your script write, math.randomseed(os.time). That makes it so that it uses a different seed each time it generates.

0
I'll accept it but not sure if that will work, I am at school atm. I'll try when I get home. FiredDusk 1466 — 8y
Ad

Answer this question