Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeamDeathmatch = {}
- local Settings = {
- DefaultRoundTime = 300,
- DefaultMaxScore = 50,
- DefaultOutscore = 999,
- }
- --Type: GameMode
- --Name: TeamDeathmatch
- --Desc: Basic TDM
- --Author: streetrogue
- --Services
- local Debris = game:GetService("Debris")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- --Main Variables
- local MainScript = script.Parent.Parent.Parent
- --Dependencies
- local GlobalFunctions = require(MainScript.GlobalFunctions)
- --Runtime fetched values
- local MapData = nil
- local MapModel = nil
- local GlobalSettings = GlobalFunctions.ReturnGameSettings
- local ReplicatedData = ReplicatedStorage.ModeData
- local ForceEnd = false
- function TeamDeathmatch.runMode()
- local TimeLimit = (GlobalSettings.Timer and GlobalSettings.Duration) or 9999
- local RoundStart = 0
- local RoundRunning = true
- local startTime = tick()
- for i,v in pairs(Players:GetPlayers()) do
- v.Character.Humanoid.Died:connect(function()
- if v.Team == game.Teams.Red then
- ReplicatedData.RedScore.Value = ReplicatedData.RedScore.Value + 1
- elseif v.Team == game.Teams.Blue then
- ReplicatedData.BlueScore.Value = ReplicatedData.BlueScore.Value + 1
- end
- end)
- while tick() < startTime + TimeLimit and ReplicatedData.RedScore.Value < GlobalSettings.MaxScore and ReplicatedData.BlueScore.Value < GlobalSettings.MaxScore and not ForceEnd do
- wait(0.5)
- local timeDelta = tick() - startTime
- ReplicatedData.Timer.Value = GlobalFunctions.ConvertTime(TimeLimit - timeDelta)
- end
- if GlobalSettings.Timer.Value and ReplicatedData.Timer.Value <= 0 then
- GlobalFunctions.RoundEnd("Time has ran out!")
- elseif ReplicatedData.RedScore.Value == GlobalSettings.MaxScore then
- GlobalFunctions.RoundEnd("Red has won!")
- elseif ReplicatedData.BlueScore.Value == GlobalSettings.MaxScore then
- GlobalFunctions.RoundEnd("Blue has won!")
- else
- GlobalFunctions.RoundEnd("The host has ended this round early.")
- end
- for i,v in pairs(Players:GetGetPlayers()) do
- v.Team = game.Teams.Spectators
- v:LoadCharacter()
- end
- ForceEnd = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement