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

Why Is my Code not Working?

Asked by 8 years ago

I am trying to spawn a map, with this code:

    statustag.Value = "Loading Map"
    timertag.Value = -1
    mapholder:ClearAllChildren()
    wait(2)
    local allmaps = maps:GetChildren()
    local newmap = allmaps[math.random(1, #allmaps)]:clone()
    newmap.Parent = mapholder
    wait(2)

Which is in a while true do loop, with an end and all. But, when the map spawns, it disapears right afterwards, killing the players.

0
I have bonus stuff in there too. nforeman 15 — 8y

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
8 years ago

You forgot to let the script know whether or not the game ended.

Use a BoolValue for a game running (or anything else really) to get the script to wait until the game ends to unload the map and teleport the players.

statustag.Value = "Loading Map"
timertag.Value = -1
mapholder:ClearAllChildren()
wait(2)
local allmaps = maps:GetChildren()
local newmap = allmaps[math.random(1, #allmaps)]:clone()
newmap.Parent = mapholder
repeat wait() until game.ServerStorage.GameRunning = false --Something like that

How you change GameRunning or whatever you want to use for the game status is up to you, and should just be a matter of fine-tuning your other scripts. Hope i helped you with that!

Ad

Answer this question