What I want to happen is, once there are two players, the round starts in 20 seconds, then all the players are teleported to either map 1 or map 2, but I have a couple of issues.
here are a few that I noticed.
-player1 spawns in wrong place --not sure if this is a roblox error or not -bikes are same color -sometimes instances are created twice
this is my main script where the "Start" bindableevent is fired when a player joins, there are at least two players, and a game is not in progress
game.ReplicatedStorage.Bindables.Start.Event:Connect(function() local MAPS = {"DeadlineMap1","DeadlineMap2"} for i = 20, 0, -1 do game.ReplicatedStorage.RemoteEvents.Timer:FireAllClients(i) wait(1) end game.ReplicatedStorage.RemoteEvents.GAMETIMER:FireAllClients() local MAP_CHOSEN = MAPS[math.random(1,#MAPS)] local PLAYERS = game.Players:GetPlayers() print("this thing started") for _, v in pairs(PLAYERS) do PART_COLOR = Instance.new("Color3Value") PART_COLOR.Parent = v PART_COLOR.Name = "playerColor" PART_COLOR.Value = BrickColor.Random().Color local I = Instance.new("IntValue") I.Parent = v I.Name = "I" for i = 1, #PLAYERS do I.Value = i end end for i = 1,#PLAYERS do bike = game.ServerStorage.Deadline["DeadlineBike"..(i)]:Clone() for _, colors in pairs(bike:GetChildren()) do if colors.Name == "Neon" then colors.Color = PART_COLOR.Value end if colors.Name == "Neon1" then colors.Color = PART_COLOR.Value end if colors.Name == "Neon2" then colors.Color = PART_COLOR.Value end if colors.Name == "Neon3" then colors.Color = PART_COLOR.Value end end for _, colormes in pairs(bike.COLOR_ME:GetChildren()) do colormes.Color = PART_COLOR.Value end for _, tires in pairs(bike:GetChildren()) do if tires.Name == "Tire" then local trail = tires:FindFirstChild("Trail") if trail then trail.Color = ColorSequence.new(PART_COLOR.Value, PART_COLOR.Value) end end end bike.Parent = workspace bike:MakeJoints() end if MAP_CHOSEN == "DeadlineMap1" then print(MAP_CHOSEN.." was selected") game.ServerStorage.Deadline.DeadlineMap1:Clone().Parent = workspace for _, players in pairs(game.Players:GetPlayers()) do local X = math.random(-147.75,148.25) local Z = math.random(-154.15,143.85) local PlayersPosition = Vector3.new(X,1244,Z) local PLR_POS = Instance.new("Vector3Value") PLR_POS.Value = PlayersPosition PLR_POS.Name = "SpawnPos" PLR_POS.Parent = players:WaitForChild("leaderstats") players.Character:MoveTo(PlayersPosition) players.Character.Humanoid.JumpPower = 0 players.Character.Humanoid.WalkSpeed = 1 bike:SetPrimaryPartCFrame(CFrame.new(players.Character.HumanoidRootPart.Position-Vector3.new(0,6.5,0))) end elseif MAP_CHOSEN == "DeadlineMap2" then print(MAP_CHOSEN.." was selected") game.ServerStorage.Deadline.DeadlineMap2:Clone().Parent = workspace for _, players in pairs(game.Players:GetPlayers()) do local X = math.random(-147.75,148.25) local Z = math.random(-154.15,143.85) local PlayersPosition = Vector3.new(X,1244,Z) local PLR_POS = Instance.new("Vector3Value") PLR_POS.Value = PlayersPosition PLR_POS.Name = "SpawnPos" PLR_POS.Parent = players:WaitForChild("leaderstats") players.Character:MoveTo(PlayersPosition) players.Character.Humanoid.JumpPower = 0 players.Character.Humanoid.WalkSpeed = 1 bike:SetPrimaryPartCFrame(CFrame.new(players.Character.HumanoidRootPart.Position-Vector3.new(0,6.5,0))) end end for _, plrs in pairs(game.Players:GetPlayers()) do local lives = Instance.new("IntValue") lives.Name = "Lives" lives.Parent = plrs.leaderstats lives.Value = 6 game.ReplicatedStorage.RemoteEvents.TweenGui:FireClient(plrs) end for i = 1, #PLAYERS do game.ReplicatedStorage.RemoteEvents.CreatePlayerLabels:FireAllClients(PLAYERS) end game.ReplicatedStorage.RemoteEvents.SAddThATColoRBRO:FireAllClients() end) game.ReplicatedStorage.RemoteEvents.PlayerDied.OnServerEvent:Connect(function(plr) print(plr.Name.." deaded") plr.CharacterAdded:Connect(function(char) if plr.leaderstats.Lives ~= 0 then wait() char:MoveTo(plr.leaderstats.SpawnPos.Value) local i = plr.I.Value bike = game.ServerStorage.Deadline["DeadlineBike"..(i)]:Clone() for _, colors in pairs(bike:GetChildren()) do if colors.Name == "Neon" then PART_COLOR = plr.playerColor colors.Color = PART_COLOR.Value end if colors.Name == "Neon1" then colors.Color = PART_COLOR.Value end if colors.Name == "Neon2" then colors.Color = PART_COLOR.Value end if colors.Name == "Neon3" then colors.Color = PART_COLOR.Value end end for _, colormes in pairs(bike.COLOR_ME:GetChildren()) do colormes.Color = PART_COLOR.Value end for _, tires in pairs(bike:GetChildren()) do if tires.Name == "Tire" then local trail = tires:FindFirstChild("Trail") if trail then trail.Color = ColorSequence.new(PART_COLOR.Value, PART_COLOR.Value) end end end bike:SetPrimaryPartCFrame(CFrame.new(plr.Character.HumanoidRootPart.Position - Vector3.new(0,6,0))) bike.Parent = workspace bike:MakeJoints() plr.Character.Humanoid.JumpPower = 0 else --send message to server that player is out of lives game.ReplicatedStorage.RemoteEvents.OutOfLives:FireClient(plr) end end) end) game.ReplicatedStorage.RemoteEvents.RemoteEventNumberNine.OnServerEvent:Connect(function(player, lives, color) game.ReplicatedStorage.RemoteEvents.RemoteEventNumberTen:FireAllClients(player, lives, color) end) game.ReplicatedStorage.RemoteEvents.SendThatColorBRO.OnServerEvent:Connect(function(player, color) game.ReplicatedStorage.RemoteEvents.SendThatColorBackBRO:FireAllClients(player,color) end)
any help is GREATLY appreciated