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

Random Map changer problem?

Asked by 10 years ago

I'm trying to make a random map chooser and it picks one map but then after it says "changing mapz" the message goes away and the map stays there and I want it to keep changing randomly.

01local ran = math.random(1,5)
02local msg = Instance.new("Message")
03msg.Parent = game.Workspace
04 
05while true do
06if ran == 1 then
07    game.Lighting.field1:clone().Parent = game.Workspace
08    game.StarterGui.CurrentMap.TextLabel.Text = "Current Map: City"
09    wait(30)
10    msg.Text = "Changing mapz"
11    wait(2)
12    msg:remove()
13    wait(2)
14    game.Workspace.field1:remove()
15elseif ran == 2 then
View all 52 lines...

3 answers

Log in to vote
1
Answered by 10 years ago

The variable ranis a random value set at the beginning of the script, meaning it NEVER changes from the first random result. Try putting this within the end of the while loop:

1ran = math.random(1,5)
Ad
Log in to vote
1
Answered by 10 years ago

So do I do

01local ran = math.random(1,5)
02local msg = Instance.new("Message")
03msg.Parent = game.Workspace
04 
05while true do
06if ran == 1 then
07    game.Lighting.field1:clone().Parent = game.Workspace
08    game.StarterGui.CurrentMap.TextLabel.Text = "Current Map: City"
09    wait(30)
10    msg.Text = "Changing mapz"
11    wait(2)
12    msg:remove()
13    wait(2)
14    game.Workspace.field1:remove()
15elseif ran == 2 then
View all 53 lines...
Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

CamKiller10 meant the ran variable should be placed right...

1local msg = Instance.new("Message")
2msg.Parent = game.Workspace
3 
4while true do
5local ran = math.random(1,5)                -- Here.
6if ran == 1 then

Answer this question