maps = game.ServerStorage.Maps:GetChildren() map = maps[math.random(1, #maps)] map:Clone().Parent = game.Workspace for _,player in pairs(game.Players:GetPlayers()) do if player.Character then spawns = map.Spawns:GetChildren() player.Character:MoveTo(spawns[math.random(1, #spawns)].Position) end end
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?
Okay so what you have laid out is spawning players on a random map. Maybe make an intermission period. This will be really basic.
while true do wait(30)--intermission maps = game.ServerStorage.Maps:GetChildren() map = maps[math.random(1, #maps)] map:Clone().Parent = game.Workspace for _,player in pairs(game.Players:GetPlayers()) do if player.Character then spawns = map.Spawns:GetChildren() player.Character:MoveTo(spawns[math.random(1, #spawns)].Position) end end wait(300) for i,player in pairs(game.Players:GetPlayers()) do if player.Character then player.Character.Head:remove() end end end
that is a basic game script but you mentioned teams correct?
while true do wait(30)--intermission maps = game.ServerStorage.Maps:GetChildren() map = maps[math.random(1, #maps)] map:Clone().Parent = game.Workspace blue = 0 red = 0 local teamplay = game.Players.GetChildren() for i = 1,game.Players.NumPlayers do local ran = math.random(1,game.Players.NumPlayers) if blue == red then -- if they are the same it is randomely generated br = math.random(1,2) if br == 1 then teamplay[ran].TeamColor = BrickColor.new("Bright blue") elseif br == 2 then teamplay[ran].TeamColor = BrickColor.new("Bright red") end elseif red >= blue then teamplay[ran].TeamColor = BrickColor.new("Bright red") elseif blue >= red then teamplay[ran].TeamColor = BrickColor.new("Bright blue") end end for _,player in pairs(game.Players:GetPlayers()) do if player.Character then spawns = map.Spawns:GetChildren() player.Character:MoveTo(spawns[math.random(1, #spawns)].Position) end end wait(300)-- five minutes for i,player in pairs(game.Players:GetPlayers()) do if player.Character then player.Character.Head:remove() player.TeamColor = BrickColor.new("White") end end end
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 (;
Line 6 is incomplete. You need to end it with something. All you have for Line 6 is
if player.Character then
Just fill something in between Character and then and you should be alright.