How do I make a round end when the core is destroyed?
Asked by
3 years ago Edited 3 years ago
I'm making a core defense game and I'm having problems. I want the loop to return to the beggining when the core is destroyed and I also want the round timer to stop, I've looked but cant find the solution to any.
RoundManager
ServerScriptService
ServerScript
01 | local status = game.ReplicatedStorage.Status |
02 | local players = script.Players |
03 | local maps = game.ServerStorage.Maps:GetChildren() |
04 | local Spectating = game.Teams [ "Lobby/Spectating" ] |
05 | local DTeam = game.Teams.Defenders |
06 | local RTeam = game.Teams.Raiders |
07 | local MorphRoomD = game.Workspace.MorphRoomD |
08 | local MorphRoomR = game.Workspace.MorphRoomR |
09 | local playersneeded = 1 |
10 | local roundlength = 500 |
11 | local intermissionlength = 30 |
13 | local function checkplayers() |
14 | if players.Value > = playersneeded then |
21 | local function IntermissionTimer() |
22 | for i = intermissionlength, 0 , - 1 do |
24 | status.Value = "Intermission: " ..i.. " seconds left!" |
28 | local function RoundTimer() |
29 | for i = roundlength, 0 , - 1 do |
31 | status.Value = "Round In Progress: " ..i.. " seconds left!" |
37 | local randomchosenmap = maps [ math.random( 1 ,#maps) ] |
38 | status.Value = "Map Chosen!" |
40 | status.Value = "The Chosen map will be " ..randomchosenmap.Name.. "!" |
41 | mapclone = randomchosenmap:Clone() |
42 | mapclone.Parent = workspace |
45 | local morphRoomSpawnsD = MorphRoomD.Spawns:GetChildren() |
46 | local morphRoomSpawnsR = MorphRoomR.Spawns:GetChildren() |
48 | for i,player in pairs (game.Players:GetPlayers()) do |
49 | if player.Team = = DTeam then |
50 | local char = player.Character or player.CharacterAdded:Wait() |
51 | local RandomMorphRoomSpawnD = morphRoomSpawnsD [ math.random( 1 ,#morphRoomSpawnsD) ] |
52 | char.HumanoidRootPart.CFrame = RandomMorphRoomSpawnD.CFrame |
53 | elseif player.Team = = RTeam then |
54 | local char = player.Character or player.CharacterAdded:Wait() |
55 | local RandomMorphRoomSpawnR = morphRoomSpawnsR [ math.random( 1 ,#morphRoomSpawnsR) ] |
56 | char.HumanoidRootPart.CFrame = RandomMorphRoomSpawnR.CFrame |
61 | local function destroyMap() |
65 | local function reloadAllPlayers() |
66 | for i,player in pairs (game.Players:GetPlayers()) do |
67 | player:LoadCharacter() |
72 | if checkplayers() then |
How would I implement that into my script?