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

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

01local status = game.ReplicatedStorage.Status
02local players = script.Players
03local maps = game.ServerStorage.Maps:GetChildren()
04local Spectating = game.Teams["Lobby/Spectating"]
05local DTeam = game.Teams.Defenders
06local RTeam = game.Teams.Raiders
07local MorphRoomD = game.Workspace.MorphRoomD
08local MorphRoomR = game.Workspace.MorphRoomR
09local playersneeded = 1
10local roundlength = 500
11local intermissionlength = 30
12 
13local function checkplayers()
14    if players.Value >= playersneeded then
15        return true
View all 79 lines...

How would I implement that into my script?

2 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

It is actually very simple. You just need to use the "continue" keyword at appropriate line of your script.

It looks something like:

1for i = 0, 10, 1 do
2    if (i == 5) then continue end -- It will not print 5
3    print(i)
4end

Edit: As for the round timer, you just need to make use of the "break" keyword at appropriate line of your script as well.

0
This is better than mine, please accept this one instead! NarwhalAndMe 141 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

If the core was destroyed, you would fire an event to end the round something like this might work

1local function RoundTimer()
2    for i = roundlength, 0, -1 do
3        wait(1)
4        status.Value = "Round In Progress: "..i.." seconds left!"
5    if Core == nil then
6        break
7    end
8    end
9end

Please tell me if this doesn't work or if someone notices a flaw!

0
I'll test it, I don't think it will work as timer is before core spawns but ill try with global variable! KamKam_AJHasBeenBan 37 — 3y
0
I also want to be able to use continue on the last while loop so ill try returning it. KamKam_AJHasBeenBan 37 — 3y
0
@NharwhalAndMe it only works in maps script for me so i just need to break round timer and continue last loop KamKam_AJHasBeenBan 37 — 3y

Answer this question