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

My random map generator script doesn't load the map in??

Asked by 4 years ago
Edited 4 years ago

Here's the code:

Intermission = 10 -- How long to wait in between games. PlayTime = 60 -- How long to wait during a game is going on.

while true do

wait(Intermission) 

    Maps = (math.random(1,2)) -- This chooses a random map. 

    if Maps == 1 then -- If it chose the Office Map, then load everything.
    Message = game.Players.LocalPlayer.PlayerGui.Output.Message
    Message.Text = "Map: Chapel, by KingIce1310 [Small map]" -- Change "The Office" to the map name, and if you want give credit to the map creator.
    wait(5) -- Wait 5 seconds.
    Message.Text = "Loading Map."
    wait(.5)
    Message.Text = "Loading Map.."
    wait(.5)
    Message.Text = "Loading Map..."
    wait(.5) 
    Message.Text = "Loading Map."
    wait(.1)
    Message.Text = "Giving tools"
    wait(.1)
    Message.Text = "Teleporting Players"
    wait(.5)
    map = game.Lighting:FindFirstChild("ChapelMap"):Clone() --Change "Office" to the map name. 
    map.Parent = game.Workspace
    map.Name = "Map"
    map:MakeJoints()
    target = game.Workspace.Map["Tele Brick"] -- Where players teleport. Removing it will cause players to fall. 
    for i, v in pairs(game.Players:GetChildren()) do
    v.Character.HumanoidRootPart.CFrame = target.CFrame + Vector3.new(0,4,0) -- Teleport all players to the target.
    Message.Text = "Good luck!"
    wait(2)
    Message.Transparency = 1    
    end
    wait(60) -- How long you want all games to be.
    Message.Transparency = .2
    game.Workspace.Map:remove()
end 

    if Maps == 2 then -- If it chose the Office Map, then load everything.
    Message = game.Players.LocalPlayer.PlayerGui.Output.Message
    Message.Text = "Map: Free Model Map, by loads of people lmaoo [Medium map]" -- Change "The Office" to the map name, and if you want give credit to the map creator.
    wait(5) -- Wait 5 seconds.
    Message.Text = "Loading Map."
    wait(.5)
    Message.Text = "Loading Map.."
    wait(.5)
    Message.Text = "Loading Map..."
    wait(.5) 
    Message.Text = "Loading Map."
    wait(.1)
    Message.Text = "Giving tools"
    wait(.1)
    Message.Text = "Teleporting Players"
    wait(.5)
    map = game.Lighting:FindFirstChild("FreeModelMap"):Clone() --Change "Science Lab" to the map name. 
    map.Parent = game.Workspace
    map.Name = "Map"
    map:MakeJoints()
    target = game.Workspace.Map["Tele Brick"] -- Where players teleport. Removing it will cause players to fall. 
    for i, v in pairs(game.Players:GetChildren()) do
    v.Character.HumanoidRootPart.CFrame = target.CFrame + Vector3.new(0,4,0) -- Teleport all players to the target.
    Message.Text = "Good luck!"
    wait(2)
    Message.Transparency = 1    
    end
    wait(PlayTime) -- How long you want all games to be.
    Message.Transparency = .2
    game.Workspace.Map:remove()
end 

end

I've tried to debug it but it won't do anything.

1 answer

Log in to vote
0
Answered by 4 years ago
  1. This shouldn't be in a LocalScript. If it's not, don't use game.Players.LocalPlayer. There are different ways you can reference a player from a server script. This will show you them: https://scriptinghelpers.org/questions/58244/how-do-i-reference-the-player-from-a-server-script

  2. You might want to change the name of your maps. Using only numbers for them will probably mess the game up. You could name them "Office" and "Science Lab" or "Map1" and "Map2".

I would also suggest cutting it down more so you don't have to repeat the same code over again.

Hope this helps!

Ad

Answer this question