#Game over system
255 messages · Page 1 of 1 (latest)
are you sure your following the tutorial right
yea i did everything they did, everything else works except for this part
@jolly nexus do you know what i could do to fix it?
lemme
print("Game Over")
you dont need the if and break
because the repeat until checks if the game is over already
yea
ok
but how do i make it so that when the gameover event happens, the waves stop happening
here lemme ss it
yea, a wave of enemys coming out
when the base health is 0
it will stop them from spawning
thats what the break was for
to stop the waves from happening
it repeats until all 15 waves are done
aight
ur putting the code outside the repeat loop
look at this
put it isnide of the repeat loop
and how would i do that 
repeat loop ends at until and then whatever you put after it and starts at repeat
so put it between line 108 and 110
should be that
ok lemme try it
the error is gone so thats a good sign
yea nah the waves still happen
even though the break is in place
why would it stop
idk that was the point of having the break
arent you just printing?
when is the game supposed to end?
after 15 waves
might want to remake some of this script?
the repeat loop doesnt wouldnt stop the waves anyway
so the repeat loop is messed up and seemingly useless rn until whatever else is broken is fixed
after the 15 waves it says game over
** You are now Level 9! **
i thought you said it didnt work?
yea after 15 waves it prints game ovr
but i wanted it to print game over once the "gameOverEvent" is triggered
what does gameOverEvent do?
game over event is triggered when the "Base" health is <= 0, and that causes the base to display "Base Destroyed"
thats the base
thats the script for the base
the base displays the current health
so like it would say "Base 500/500
smth like that
so my goal was, whenever the gameOverEvent is triggered, the wave system will stop
oh, why dont you make it turn gameOver to true or something to that manner?
same script as this
you could try connecting this directly to the event and stopping the waves maybe? im bout to go to sleep though
idk how to do that
i mean couldnt you just add the stop code inside of here?
what code stops it at wave 15?
a couple lines above this
how does it stop though? thats just spawning the mobs
no?
cause there's an if statement inside of the loop
that only checks for gameOver
maybe that's the issue? i cant really
tell
i can send the whole script if you want
alright
gl g
thanks
um
** You are now Level 1! **
you use a remote event to check when the game is over?
ohh
ye go ahead and send the entire thing
alright
base script
the top ones are for the wave system
ik its messy but
😭
why is this part not in the loop
if wave == 1
then task.wait(wave + 15)
end
wave isn't defined in that part of the code so it doesn't know what to check for
no wonder
dont
make a wave variable at the top and change it whenever the wave changes
local wave = 0
then when the wave is changed
you would make the variable = to the wave
that way other parts of the script know what wave it's on
instead of just the for loop
like there or
yeah that'll work
ok what next
change what to current wave
the variable you just made
ye
okay
try testing it
alright lol
what is it supposed to print
** You are now Level 2! **
oh wait
lmfao
it's because the for loop is still running
so it never gets to the repeat
well yeah but that's after wave 15
the code is still running
task.spawn(function)
end)
put the for loop inside this
no the entire thing
yes
oh okay
that's part of the loop
yes, sorry
np
local ServerStorage = game:GetService("ServerStorage")
local bindables = ServerStorage:WaitForChild("Bindables")
local gameOverEvent = bindables:WaitForChild("GameOver")
local base = require(script.Base)
local mob = require(script.Mob)
local tower = require(script.Tower)
local map = workspace.Grassland
local gameOver = false
base.Setup(map, 500)
gameOverEvent.Event:Connect(function()
gameOver = true
end)
local CurrentWave = 0
task.wait(10)
task.spawn(function()
for wave=1, 15 do
CurrentWave = wave
print("Wave", wave, "Starting")
if wave == 1 then workspace.Sound.Playing = true
end
if wave <= 1 then
mob.Spawn("Zombie", 6, map)
elseif wave <= 2 then
mob.Spawn("Zombie", 4, map)
mob.Spawn("Noob", 2, map)
mob.Spawn("Zombie", 4, map)
elseif wave <= 3 then
mob.Spawn("Zombie", 8, map)
mob.Spawn("Noob", wave, map)
elseif wave <= 4 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Noob", wave, map)
mob.Spawn("Zombie", 5, map)
elseif wave <= 5 then
mob.Spawn("Zombie", 12, map)
mob.Spawn("Noob", 5, map)
elseif wave <= 6 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Noob", 5, map)
elseif wave <= 7 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 8 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Noob", 5, map)
mob.Spawn("Zombie", 5, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Zombie", 5, map)
elseif wave <= 9 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Mech", 3, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 10 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 15, map)
elseif wave <= 11 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 20, map)
elseif wave <= 12 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 7, map)
mob.Spawn("Noob", 15, map)
mob.Spawn("Zombie", 20, map)
elseif wave <= 13 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Mech", 10, map)
mob.Spawn("Noob", 15, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 14 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Mech", 10, map)
mob.Spawn("Noob", 20, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 15 then
mob.Spawn("Zombie", 2, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Zombie", 3, map)
mob.Spawn("Noob", 5, map)
mob.Spawn("Teddy",1, map)
mob.Spawn("Noob", 10, map)
end
end)
task.wait(2)
print("Wave", wave, "Ended")
task.wait(3)
end
repeat
task.wait(1)
if gameOver then
print("Game Over")
break
end
if wave >= 1
then task.wait(wave + 15)
end
until #workspace.Mobs:GetChildren() == 0 or gameOver
there u go
do you want me to send the other script too
for the base health
well that was supposed to make it so that after the wave starts, it has to wait like, 15 seconds before it ends
in case you are afk at the beginning
I see
it wont be wave 15 by the time you get back
but if all mobs die, then the wave ends right then and therer

local ServerStorage = game:GetService("ServerStorage")
local bindables = ServerStorage:WaitForChild("Bindables")
local gameOverEvent = bindables:WaitForChild("GameOver")
local base = require(script.Base)
local mob = require(script.Mob)
local tower = require(script.Tower)
local map = workspace.Grassland
local gameOver = false
base.Setup(map, 500)
gameOverEvent.Event:Connect(function()
gameOver = true
end)
local CurrentWave = 0
task.wait(10)
task.spawn(function()
for wave=1, 15 do
CurrentWave = wave
print("Wave", wave, "Starting")
if wave == 1 then workspace.Sound.Playing = true
end
if wave <= 1 then
mob.Spawn("Zombie", 6, map)
elseif wave <= 2 then
mob.Spawn("Zombie", 4, map)
mob.Spawn("Noob", 2, map)
mob.Spawn("Zombie", 4, map)
elseif wave <= 3 then
mob.Spawn("Zombie", 8, map)
mob.Spawn("Noob", wave, map)
elseif wave <= 4 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Noob", wave, map)
mob.Spawn("Zombie", 5, map)
elseif wave <= 5 then
mob.Spawn("Zombie", 12, map)
mob.Spawn("Noob", 5, map)
elseif wave <= 6 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Noob", 5, map)
elseif wave <= 7 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 8 then
mob.Spawn("Zombie", 5, map)
mob.Spawn("Noob", 5, map)
mob.Spawn("Zombie", 5, map)
mob.Spawn("Mech", 1, map)
mob.Spawn("Zombie", 5, map)
elseif wave <= 9 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Mech", 3, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 10 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 15, map)
elseif wave <= 11 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Noob", 10, map)
mob.Spawn("Zombie", 20, map)
elseif wave <= 12 then
mob.Spawn("Zombie", 15, map)
mob.Spawn("Mech", 7, map)
mob.Spawn("Noob", 15, map)
mob.Spawn("Zombie", 20, map)
elseif wave <= 13 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Mech", 10, map)
mob.Spawn("Noob", 15, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 14 then
mob.Spawn("Zombie", 10, map)
mob.Spawn("Mech", 10, map)
mob.Spawn("Noob", 20, map)
mob.Spawn("Zombie", 10, map)
elseif wave <= 15 then
mob.Spawn("Zombie", 2, map)
mob.Spawn("Mech", 5, map)
mob.Spawn("Zombie", 3, map)
mob.Spawn("Noob", 5, map)
mob.Spawn("Teddy",1, map)
mob.Spawn("Noob", 10, map)
end
if #workspace.Mobs:GetChildren() == 0 or gameOver then
print("Game Over")
break
end
if CurrentWave >= 1 then
task.wait(CurrentWave + 15)
end
print("Wave", CurrentWave, "Ended")
end
end)
okay see if this works
can you add something to it rq while im running it
can you add a task.wait before the "print wave ended" thing right at the end
task.wait(3)
sure
right after here
ty
who let bro cook
i actually love youso much bro
holy
roberto
come here
thanks man


