Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local badgeModule = require(game.ReplicatedStorage.Modules.BadgeModule)
- local gameSettings = game.ReplicatedStorage.GameSettings
- local gamePoints = game.ReplicatedStorage.GamePoints
- local maps = game.ServerStorage.Maps
- local lastMap = ""
- local function LoadMap()
- -- Map voting goes here
- gameSettings.RoundType.Value = "LOADING MAP"
- local m = ""
- repeat
- m = maps:GetChildren()[math.random(#maps:GetChildren())].Name
- wait(0.1)
- until m ~= lastMap
- lastMap = m
- local map = maps[m]:Clone()
- map.Name = "Map"
- map.Parent = game.Workspace
- local function change(obj)
- for _, v in pairs(obj:GetChildren()) do
- if v:IsA("BasePart") then
- v.CustomPhysicalProperties = PhysicalProperties.new(1, 4, 0)
- else
- change(v)
- end
- end
- end
- change(map)
- -- Replace this with a way to wait for all the clients to load the map
- wait(5)
- return map
- end
- local rounds = {
- -- FFA
- FFA = function()
- gameSettings.RoundType.Value = "FFA"
- local winner
- for _, p in pairs(game.Players:GetPlayers()) do
- p.TeamColor = BrickColor.new("White")
- p.Neutral = true
- local pts = Instance.new("NumberValue")
- pts.Name = p.Name
- pts.Parent = gamePoints
- end
- local pa = game.Players.PlayerAdded:connect(function(player)
- player.TeamColor = BrickColor.new("White")
- player.Neutral = true
- local pts = Instance.new("NumberValue")
- pts.Name = player.Name
- pts.Parent = gamePoints
- end)
- local pl = game.Players.PlayerRemoving:connect(function(player)
- gamePoints[player.Name]:Destroy()
- end)
- local pkp
- pkp = game.ReplicatedStorage.Events.PlayerKilledPlayer.Event:connect(function(a, b)
- gamePoints[a.Name].Value = gamePoints[a.Name].Value + 1
- if gamePoints[a.Name].Value >= 30 then
- badgeModule.AwardBadge(a, "Win")
- winner = a
- pkp:disconnect()
- end
- end)
- gameSettings.SpawnEnabled.Value = true
- gameSettings.Timer.Value = 360
- repeat
- gameSettings.Timer.Value = gameSettings.Timer.Value - 1
- wait(1)
- until gameSettings.Timer.Value == 0 or winner
- pa:disconnect()
- pl:disconnect()
- pkp:disconnect()
- if winner then
- gameSettings.RoundType.Value = string.upper(winner.Name) .. " WINS"
- wait(5)
- else
- local winner = gamePoints:GetChildren()[1]
- for _, v in pairs(gamePoints:GetChildren()) do
- if v.Value > winner.Value then
- winner = v
- end
- end
- winner = winner.Name
- if game.Players:FindFirstChild(winner) then
- badgeModule.AwardBadge(game.Players[winner], "Win")
- end
- gameSettings.RoundType.Value = string.upper(winner) .. " WINS"
- wait(5)
- end
- --wait(2)
- end;
- -- TDM
- TDM = function()
- gameSettings.RoundType.Value = "TDM"
- local players = game.Players:GetPlayers()
- local scrambled = {}
- repeat
- local i = math.random(#players)
- table.insert(scrambled, players[i])
- table.remove(players, i)
- until #players == 0
- for i, player in pairs(scrambled) do
- player.Neutral = false
- if i % 2 == 0 then
- player.TeamColor = BrickColor.new("Bright blue")
- else
- player.TeamColor = BrickColor.new("Bright red")
- end
- end
- local pa = game.Players.PlayerAdded:connect(function(player)
- player.Neutral = false
- local a, b = 0, 0
- for _, p in pairs(game.Players:GetPlayers()) do
- if p ~= player then
- if p.TeamColor == BrickColor.new("Bright blue") then
- a = a + 1
- else
- b = b + 1
- end
- end
- end
- if a > b then
- player.TeamColor = BrickColor.new("Bright red")
- else
- player.TeamColor = BrickColor.new("Bright blue")
- end
- end)
- local aPts = Instance.new("NumberValue")
- aPts.Name = "Bright blue"
- aPts.Parent = gamePoints
- local bPts = Instance.new("NumberValue")
- bPts.Name = "Bright red"
- bPts.Parent = gamePoints
- local pkp = game.ReplicatedStorage.Events.PlayerKilledPlayer.Event:connect(function(a, b)
- if a.TeamColor == BrickColor.new("Bright blue") then
- aPts.Value = aPts.Value + 1
- else
- bPts.Value = bPts.Value + 1
- end
- end)
- gameSettings.SpawnEnabled.Value = true
- gameSettings.Timer.Value = 360
- repeat
- gameSettings.Timer.Value = gameSettings.Timer.Value - 1
- wait(1)
- until gameSettings.Timer.Value == 0 or aPts.Value >= 50 or bPts.Value >= 50
- pa:disconnect()
- pkp:disconnect()
- if aPts.Value > bPts.Value then
- for _, p in pairs(game.Players:GetPlayers()) do
- if p.TeamColor == BrickColor.new(aPts.Name) then
- badgeModule.AwardBadge(p, "Win")
- end
- end
- gameSettings.RoundType.Value = "BLUE TEAM WINS"
- wait(5)
- elseif bPts.Value > aPts.Value then
- for _, p in pairs(game.Players:GetPlayers()) do
- if p.TeamColor == BrickColor.new(bPts.Name) then
- badgeModule.AwardBadge(p, "Win")
- end
- end
- gameSettings.RoundType.Value = "RED TEAM WINS"
- wait(5)
- else
- gameSettings.RoundType.Value = "TIE"
- wait(5)
- end
- end;
- -- KOTH
- KOTH = function()
- gameSettings.RoundType.Value = "KOTH"
- local players = game.Players:GetPlayers()
- local scrambled = {}
- repeat
- local i = math.random(#players)
- table.insert(scrambled, players[i])
- table.remove(players, i)
- until #players == 0
- for i, player in pairs(scrambled) do
- player.Neutral = false
- if i % 2 == 0 then
- player.TeamColor = BrickColor.new("Bright blue")
- else
- player.TeamColor = BrickColor.new("Bright red")
- end
- end
- local pa = game.Players.PlayerAdded:connect(function(player)
- player.Neutral = false
- local a, b = 0, 0
- for _, p in pairs(game.Players:GetPlayers()) do
- if p ~= player then
- if p.TeamColor == BrickColor.new("Bright blue") then
- a = a + 1
- else
- b = b + 1
- end
- end
- end
- if a > b then
- player.TeamColor = BrickColor.new("Bright red")
- else
- player.TeamColor = BrickColor.new("Bright blue")
- end
- end)
- local aPts = Instance.new("NumberValue")
- aPts.Name = "Bright blue"
- aPts.Parent = gamePoints
- local bPts = Instance.new("NumberValue")
- bPts.Name = "Bright red"
- bPts.Parent = gamePoints
- local function GetPlayersInRadius(point, radius)
- local players = {}
- for _, player in pairs(game.Players:GetPlayers()) do
- if player.Character and player.Character.Parent and player.Character:FindFirstChild("HumanoidRootPart") and player.Character.Humanoid.Health > 0 then
- local distance = (point - player.Character.HumanoidRootPart.Position).magnitude
- if distance <= radius then
- table.insert(players, player)
- end
- end
- end
- return players
- end
- -- ADD SOME GAMEMODE STUFF HERE
- local requiredPoints = 500
- local hill = game.Workspace:FindFirstChild("KOTHHILL", true)
- local point = game.ReplicatedStorage.Objects.KOTHPoint:Clone()
- point.Parent = hill.Parent
- point:SetPrimaryPartCFrame(hill.CFrame * CFrame.new(0, 1.6, 0))
- gameSettings.SpawnEnabled.Value = true
- gameSettings.Timer.Value = 360
- repeat
- gameSettings.Timer.Value = gameSettings.Timer.Value - 1
- local players = GetPlayersInRadius(point.PrimaryPart.Position, 40)
- local blue, red = 0, 0
- local color = BrickColor.new("White")
- for _, player in pairs(players) do
- if player.TeamColor == BrickColor.new("Bright blue") then
- blue = blue + 1
- elseif player.TeamColor == BrickColor.new("Bright red") then
- red = red + 1
- end
- if gameSettings.Timer.Value % 6 == 0 then
- badgeModule.AwardBadge(player, "Holding Hill")
- end
- end
- if blue > 0 or red > 0 then
- if blue == red then
- color = BrickColor.new("Magenta")
- elseif blue > red then
- color = BrickColor.new("Bright blue")
- aPts.Value = aPts.Value + blue - red
- elseif red > blue then
- color = BrickColor.new("Bright red")
- bPts.Value = bPts.Value + red - blue
- end
- end
- for _, v in pairs(point:GetChildren()) do
- if v:IsA("BasePart") then
- v.BrickColor = color
- end
- end
- point.Crystal.BillboardGui.ImageLabel.ImageColor3 = color.Color
- wait(1)
- until gameSettings.Timer.Value == 0 or aPts.Value >= requiredPoints or bPts.Value >= requiredPoints
- pa:disconnect()
- --pkp:disconnect()
- if aPts.Value > bPts.Value then
- for _, p in pairs(game.Players:GetPlayers()) do
- if p.TeamColor == BrickColor.new(aPts.Name) then
- badgeModule.AwardBadge(p, "Win")
- end
- end
- gameSettings.RoundType.Value = "BLUE TEAM WINS"
- wait(5)
- elseif bPts.Value > aPts.Value then
- for _, p in pairs(game.Players:GetPlayers()) do
- if p.TeamColor == BrickColor.new(bPts.Name) then
- badgeModule.AwardBadge(p, "Win")
- end
- end
- gameSettings.RoundType.Value = "RED TEAM WINS"
- wait(5)
- else
- gameSettings.RoundType.Value = "TIE"
- wait(5)
- end
- end;
- }
- local rewards = {
- ["Weapon Crate"] = 4;
- ["Armor Crate"] = 6;
- ["Equipment Crate"] = 1;
- }
- local weightedRewards = {}
- for r, n in pairs(rewards) do
- for i = 1, n do
- table.insert(weightedRewards, r)
- end
- end
- local function NewRound()
- local oldMap = game.Workspace:FindFirstChild("Map")
- if oldMap then
- oldMap:Destroy()
- end
- local map = LoadMap()
- local gamemodes = {}
- for _, v in pairs(map.Gamemodes:GetChildren()) do
- table.insert(gamemodes, v.Name)
- end
- rounds[gamemodes[math.random(#gamemodes)]]()
- gameSettings.SpawnEnabled.Value = false
- for _, player in pairs(game.Players:GetPlayers()) do
- local playerData = game.ReplicatedStorage.Data:FindFirstChild(player.Name)
- if playerData then
- if playerData.Playing.Value then
- playerData.Playing.Value = false
- game.ServerScriptService.SpawnScript.LoadCharacter:Fire(player)
- end
- local reward = weightedRewards[math.random(#weightedRewards)]
- playerData.GameStats.Reward.Value = reward
- if playerData.Crates:FindFirstChild(reward) then
- playerData.Crates[reward].Value = playerData.Crates[reward].Value + 1
- else
- local c = Instance.new("NumberValue")
- c.Name = reward
- c.Value = 1
- c.Parent = playerData.Crates
- end
- end
- end
- wait(1)
- game.ReplicatedStorage.Remotes.RoundEnd:FireAllClients()
- end
- while true do
- if game.Players.NumPlayers > 0 then
- NewRound()
- end
- for _, player in pairs(game.Players:GetPlayers()) do
- local playerData = game.ReplicatedStorage.Data:FindFirstChild(player.Name)
- if playerData then
- local score = badgeModule.CalculatePoints(player)
- playerData.Credits.Value = playerData.Credits.Value + score
- end
- end
- for _, v in pairs(game.Workspace:GetChildren()) do
- if v.Name == "Turret" then
- v:Destroy()
- end
- end
- game.ServerScriptService.CrateScript.Disabled = true
- game.Workspace.Crates:ClearAllChildren()
- gameSettings.RoundType.Value = "INTERMISSION"
- gameSettings.Timer.Value = 20
- repeat
- gameSettings.Timer.Value = gameSettings.Timer.Value - 1
- wait(1)
- until gameSettings.Timer.Value == 0
- game.ServerScriptService.CrateScript.Disabled = false
- gamePoints:ClearAllChildren()
- for _, d in pairs(game.ReplicatedStorage.Data:GetChildren()) do
- d.GameStats.Streak.Value = 0
- d.GameStats.Kills.Value = 0
- d.GameStats.Deaths.Value = 0
- d.GameStats.LastKiller.Value = nil
- d.GameStats.Badges:ClearAllChildren()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement