Main game script at ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
local ls = Instance.new("Folder", plr)
ls.Name = "leaderstats"
local cash = Instance.new("IntValue",ls)
cash.Name = "Cash"
cash.Value = 0
end)
--//Variables
local maps = game:GetService("ServerStorage").Maps:GetChildren()
local Title = game.StarterGui.MapSelector.Title
local spawns = game.Workspace.Spawns:GetChildren()
local status = game.ReplicatedStorage.Status
local players = game:GetService("Players")
local randomText = {"Drinking Water...","Subscribing To MrBeast...", "Finishing a task in Among Us...", "Banana...", "YOU AINT FROM MICHIGAN IF YOU'VE NEVER DONE THIS BEFOH!", "How do you d", "Pinpointing on finding out who's Joe...", "gg/fart", "how do you code a game", "Among Us 2 When?", "When The Imposter is SUS!", "IMPOSTER!!1 IMPOSTER WARNING!!!!", "trollface emote", "ugKFCvBxfg", "pronounce amogus... but backwards :D", "j", "how is this man?", "link is hot", "game.workspace.Joe.Mama", "jigsaw is good, but jixaw? yeah, good man"}
local randomMap = maps[math.random(1, #maps)]
local current = randomMap.Name
local drumroll = script.drumroll
local fanfare = script.fanfare
local music = script.Music
ti = 0
--//GameHandler Variables
local glock22 = script:WaitForChild("Glock 22")
local aa12 = script:WaitForChild("AA-12")
local dbs = script:WaitForChild("Double Barrel")
local l96a1 = script:WaitForChild("L96A1")
local mobs = {[10] = script:WaitForChild("HardMob"), [5] = script:WaitForChild("MediumMob"), [1] = script:WaitForChild("EasyMob")}
local mobSpawns = workspace:WaitForChild("MobSpawns")
local statusValue = game.ReplicatedStorage:WaitForChild("Status")
local respawnWave = 15
local startingMobs = 4
local maxWave = math.huge
--//Code
while wait() do
ti = 30
if #players:GetPlayers() >= 2 then
repeat
ti = ti - 1
status.Value = "Intermission... "..ti.." Seconds Left"
wait(1)
until ti == 0
status.Value = "Currently Choosing Map..."
wait(1.5)
--//Basically this is a lie ^, it starts under here
status.Value = "Chosen Map Is..."
music.Playing = false
randomMap:Clone().Parent = workspace
drumroll.Playing = true
drumroll.Ended:Wait()
--//IDK how this doesn't work but OKAY?
status.Value = "Chosen Map Is... "..randomMap.Name.."!"
fanfare.Playing = true
fanfare.Ended:Wait()
music.Playing = true
status.Value = "Teleporting Players..."
wait(2)
status.Value = randomText[math.random(#randomText)]
wait(4)
status.Value = "Starting Game!"
local alivePlrs = {}
for i, plr in pairs(game.Players:GetPlayers()) do
plr:LoadCharacter()
table.insert(alivePlrs, plr)
plr.Character.Humanoid.Died:Connect(function()
table.remove(alivePlrs,alivePlrs[plr])
glock22:Clone().Parent = plr.Backpack
l96a1:Clone().Parent = plr.Backpack
aa12:Clone().Parent = plr.Backpack
dbs:Clone().Parent = plr.Backpack
end)
end
wait(2)
local plrs = game.Players:GetChildren()
for i = 1, #plrs do
if randomMap.Name == "City" then
local spawnsCity = workspace.Spawns.CitySpawns
local city = spawnsCity:GetChildren()
local citySpawn = city[math.random(1, #city)]
plrs[i].Character.HumanoidRootPart.CFrame = citySpawn.CFrame + Vector3.new(0,10,0)
elseif randomMap.Name == "Mountain" then
local spawnsMount = workspace.Spawns.MountainSpawn
local mountain = spawnsMount:GetChildren()
local mountainSpawn = mountain[math.random(1, #mountain)]
plrs[i].Character.HumanoidRootPart.CFrame = mountainSpawn.CFrame + Vector3.new(0,10,0)
-- elseif randomMap.name == "Beach" then
-- local spawnsBe = workspace.Spawns.BeachSpawn
-- local beach = spawnsBe:GetChildren()
-- local beachSpawn = beach[math.random(1, #beach)]
-- end
end
end
while true do
for i = 1, maxWave do
local mobsToSpawn = (startingMobs / 2) * (2^i)
status.Value = "Wave "..i.." starting..."
wait(3)
local mobTypeSpawn
for waveNum, mobType in pairs(mobs) do
if i >= waveNum then
mobTypeSpawn = mobType
break
end
end
while mobsToSpawn > 0 do
for x, spawner in pairs(mobSpawns:GetChildren()) do
mobsToSpawn = mobsToSpawn - 1
local CitySpawns = workspace.mobSpawns.EnemyCitySpawns:GetChildren()
local MountainSpawns = workspace.mobSpawns.EnemyCitySpawns:GetChildren()
local mobClone = mobTypeSpawn:Clone()
if spawner == "EnemyCitySpawns" and randomMap == "City" then
mobClone.HumanoirdRootPart.CFrame = spawner.CFrame + Vector3.new(0,10,0)
end
if spawner == "EnemyMountainSpawns" and randomMap == "Mountain" then
mobClone.HumanoirdRootPart.CFrame = spawner.CFrame + Vector3.new(0,10,0)
end
mobClone.Parent = workspace:WaitForChild("MobsFolder")
end
end
repeat
wait()
status.Value = "Wave " .. i .. " | "..#workspace:WaitForChild("MobsFolder"):GetChildren().. "/" ..(startingMobs / 2) * (2^ i) .. " Enemies"
until #workspace:WaitForChild("MobsFolder"):GetChildren() < 1 or #alivePlrs < 1
if #alivePlrs < 1 then
-- status.Value = "Game Over!"
-- wait(1)
-- status.Value = "Loading Game..."
break
else
for y, plrAlive in pairs(alivePlrs) do
plrAlive.leaderstats.Cash.Value = plrAlive.leaderstats.Cash.Value + (20 * i)
end
if i % respawnWave == 0 then
for z, plr in pairs(game.Players:GetPlayers()) do
plr:LoadCharacter()
glock22:Clone().Parent = plr.Backpack
l96a1:Clone().Parent = plr.Backpack
aa12:Clone().Parent = plr.Backpack
dbs:Clone().Parent = plr.Backpack
end
end
end
end
end
else
music.Playing = true
repeat
status.Value = "Waiting For Players..."
wait(2.5)
status.Value = randomText[math.random(1,#randomText)]
wait(0.5)
until #players:GetPlayers() >= 2
end
end
Textlabel / text local script in starter gui
local function updateStatus()
script.Parent.Text = game.ReplicatedStorage:WaitForChild("Status").Value
end
updateStatus()
game.ReplicatedStorage:WaitForChild("Status"):GetPropertyChangedSignal("Value"):Connect(updateStatus)