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

I can't figure out why the second map never prints out?

Asked by 4 years ago

there is a delay between the 1st map spawning but nothing is printing? heres the short code

while true do
    currentmap = math.random(2)
    if currentmap == 1 then
        print("Map 1 Selected")
            game.Lighting.WreckedMap.Parent = game.Workspace
        wait(5)
        game.Workspace.WreckedMap.Parent = game.Lighting
    if currentmap == 2 then 
        print("Map 2 Selected")
        wait(5)
        end
    end
end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

This is not good code by any means, though I fixed your problem.

Your code is saying (in plain English) if the map is 1 and the map is 2, do stuff.

This is impossible, as the variable map cannot be two things at the same time. What you meant to say is if the map is 1, do stuff. If the map is 2, do other stuff

also, math.random needs two arguments.

while true do
    currentmap = math.random(1,2)
    if currentmap == 1 then
        print("Map 1 Selected")
            game.Lighting.WreckedMap.Parent = game.Workspace
        wait(5)
        game.Workspace.WreckedMap.Parent = game.Lighting
    elseif currentmap == 2 then 
        print("Map 2 Selected")
        wait(5)
        end
    end
end

Ad

Answer this question