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

How to make a random map and team generator?

Asked by 11 years ago
01maps = game.ServerStorage.Maps:GetChildren()
02map = maps[math.random(1, #maps)]
03map:Clone().Parent = game.Workspace
04 
05for _,player in pairs(game.Players:GetPlayers()) do
06    if player.Character then
07        spawns = map.Spawns:GetChildren()
08        player.Character:MoveTo(spawns[math.random(1, #spawns)].Position)
09    end
10end

I'm trying to make a sword fighting game, and I have players spawn in the lobby and I need it to choose a map and tp the players to the spawns. There are 2 teams, red and blue. What can I add or what do I need to get this to work?

2 answers

Log in to vote
2
Answered by 11 years ago

Okay so what you have laid out is spawning players on a random map. Maybe make an intermission period. This will be really basic.

01while true do
02    wait(30)--intermission
03    maps = game.ServerStorage.Maps:GetChildren()
04    map = maps[math.random(1, #maps)]
05    map:Clone().Parent = game.Workspace
06 
07    for _,player in pairs(game.Players:GetPlayers()) do
08        if player.Character then
09               spawns = map.Spawns:GetChildren()
10         player.Character:MoveTo(spawns[math.random(1, #spawns)].Position)
11       end
12    end
13    wait(300)
14    for i,player in pairs(game.Players:GetPlayers()) do
15        if player.Character then
16            player.Character.Head:remove()
17        end
18    end
19end

that is a basic game script but you mentioned teams correct?

01while true do
02    wait(30)--intermission
03    maps = game.ServerStorage.Maps:GetChildren()
04    map = maps[math.random(1, #maps)]
05    map:Clone().Parent = game.Workspace
06    blue = 0
07    red = 0
08    local teamplay = game.Players.GetChildren()
09    for i = 1,game.Players.NumPlayers do
10        local ran = math.random(1,game.Players.NumPlayers)
11        if blue == red then -- if they are the same it is randomely generated
12            br = math.random(1,2)
13            if br == 1 then
14                teamplay[ran].TeamColor = BrickColor.new("Bright blue")
15            elseif br == 2 then
View all 37 lines...

Just create 3 teams. One Bright blue, One Bright red, and another White. Spawns are still random but if you want to create seperate spawns, I'm sure you can do it (;

0
What would be white, lobby?? NinjoOnline 1146 — 11y
0
With line 30, I can change it to600 so its 10 mins per round?? I want it to be on a GUI countdown,will that be possible?? NinjoOnline 1146 — 11y
0
And at the top with intermission, I have already a count down in GUI, and set it to change a BoolValue to True once the countdown has finished. Can I just do if game.Workspace.BoolValue.Value = true then, will that work?? NinjoOnline 1146 — 11y
0
Do the spawns in the map have to be spawnlocations or can they just be blocks? NinjoOnline 1146 — 11y
View all comments (3 more)
0
It didnt work, what do I need to add to it, what should the maps be called, what should the spawns be called, etc tec NinjoOnline 1146 — 11y
0
I have fixed it, and the maps load, but you dont tp to the teams. What do I have to add?? NinjoOnline 1146 — 11y
0
Do you have a team service with teams that are {"Bright blue","Bright red","White"}? and yes White would be intermission. The question about the intermission you can totally just do while game.Workspace.BoolValue.value == true then. soaprocks2 75 — 11y
Ad
Log in to vote
-2
Answered by 11 years ago

Line 6 is incomplete. You need to end it with something. All you have for Line 6 is

1if player.Character then

Just fill something in between Character and then and you should be alright.

0
What? NinjoOnline 1146 — 11y
0
There is nothing wrong with Line 6. coo1o 227 — 11y

Answer this question