HELP! HELP! Help! help! help

Its extremely complicated so this kit

So Its a zombie wave system and I just want to add a timer so if you dont kill all the zombies in time it teleports you back, aswell as if all players die, How would I go about doing this?
With an intermission aswell

If it is complicated to you and doesn’t suit your needs, then make your own version :neutral_face:
Also, please next time make the title of the post topic-related.

4 Likes

Sorry about the title but the kit is good I just wanted to add that timer to it but sorry

somewhere there is a game loop running in a Script in this model. its gonna look something like

repeat
    wait()
until -- condition is met

in this case it looks like the condition is that all zombies are dead. now to add to this you would add some sort of counter to keep track of the time elapsed and every second you subtract 1 from the timer. if the timer is 0 or below, the until block of the code runs.

1 Like

Thats not a timer. thats a whole round system. Theres tutorials on youtube for that.

I highly recommend learning how to script from tutorial videos instead of using kit videos. Kits can be poorly made and if you dont fully understand the script you cant connect it to other parts of the game. Unless you’re just making a toolbox game for fun.

Wanting a part of the game made for you for free isn’t scripting support. This is for scripters who get stuck on coding, don’t know why their code isn’t working, etc

2 Likes

okay sorry thanks your both the solution who do I give the solution to?

you mark as solution what helped you the most and what you feel is right.

1 Like

personally I don’t like using repeat until anymore than I have to as I find it can be a trap if you never meet the condition the code can get wonky. I prefer just putting whatever system my game uses into a while true do loop. There is a couple of ways to achieve this so that the condition stops the code from running more than once

local condition = false

while true do

task.wait(2)

print("Hi") -- prints Hi

condition = true -- condition is met

if condition then -- if condition is met then

return -- ends the loop

end

end
local condition = false

while true do

task.wait(2)

print("Hi") -- prints Hi

condition = true -- condition is met

if condition then -- if condition is met then

break -- ends the loop

end

end
1 Like

sure ill go with you but that is kind of the same with while true do. if the condition that breaks the loop isnt met itll also run forever. same with repeat. i would still say that with a complex game loop you are better off using a while loop like you suggested. though, i just quickly peaked at the kits code and this is the code responsible for one wave in a while loop:

repeat
    wait()
until workspace.ZombieSystem.Zombies.ZombiesAlive.Value == 0

Now if this is good logic is another question, but it is the code in the kit and I can’t do much about this. Adding a simple timer like I suggested does not require a whole “round system” or another while loop in the already existing while loop. and personally i do think that repeat can be used for such simple loops. if not, i wouldnt know why it would exist.
a simple example of an added timer would be:

timer = 180 -- in seconds, 3 minutes
repeat
    wait(1)
    timer -= 1
until workspace.ZombieSystem.Zombies.ZombiesAlive.Value == 0 or timer == 0 or -- implement condition that checks if all players are dead (through tags for example)

just an end note: everyone can code how they want. im just presenting a possible solution. a while loop is definitely another solution that works just as well.

edit: typo in code

2 Likes

Yes I agree

It can be. I used to use it often and eventually I stopped using it altogether. That’s my personal preference though and it mainly comes down to I like the organization of while true do loops

1 Like