Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local TeamDeathmatch = {}
  2.  
  3. local Settings = {
  4.     DefaultRoundTime = 300,
  5.     DefaultMaxScore = 50,
  6.     DefaultOutscore = 999,
  7. }
  8.  
  9. --Type: GameMode
  10. --Name: TeamDeathmatch
  11. --Desc: Basic TDM
  12. --Author: streetrogue
  13.  
  14. --Services
  15. local Debris = game:GetService("Debris")
  16. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  17. local Players = game:GetService("Players")
  18.  
  19. --Main Variables
  20. local MainScript = script.Parent.Parent.Parent
  21.    
  22. --Dependencies
  23. local GlobalFunctions = require(MainScript.GlobalFunctions)
  24.  
  25. --Runtime fetched values
  26. local MapData = nil
  27. local MapModel = nil
  28.  
  29. local GlobalSettings = GlobalFunctions.ReturnGameSettings
  30. local ReplicatedData = ReplicatedStorage.ModeData
  31. local ForceEnd = false
  32.  
  33. function TeamDeathmatch.runMode()
  34.     local TimeLimit = (GlobalSettings.Timer and GlobalSettings.Duration) or 9999
  35.     local RoundStart = 0
  36.     local RoundRunning = true
  37.     local startTime = tick()
  38.    
  39.     for i,v in pairs(Players:GetPlayers()) do
  40.         v.Character.Humanoid.Died:connect(function()
  41.             if v.Team == game.Teams.Red then
  42.                 ReplicatedData.RedScore.Value = ReplicatedData.RedScore.Value + 1
  43.             elseif v.Team == game.Teams.Blue then
  44.                 ReplicatedData.BlueScore.Value = ReplicatedData.BlueScore.Value + 1
  45.             end
  46.         end)
  47.  
  48.         while tick() < startTime + TimeLimit and ReplicatedData.RedScore.Value < GlobalSettings.MaxScore and ReplicatedData.BlueScore.Value < GlobalSettings.MaxScore and not ForceEnd do
  49.             wait(0.5)
  50.             local timeDelta = tick() - startTime
  51.             ReplicatedData.Timer.Value = GlobalFunctions.ConvertTime(TimeLimit - timeDelta)
  52.         end
  53.        
  54.         if GlobalSettings.Timer.Value and ReplicatedData.Timer.Value <= 0 then
  55.             GlobalFunctions.RoundEnd("Time has ran out!")
  56.         elseif ReplicatedData.RedScore.Value == GlobalSettings.MaxScore then
  57.             GlobalFunctions.RoundEnd("Red has won!")
  58.         elseif ReplicatedData.BlueScore.Value == GlobalSettings.MaxScore then
  59.             GlobalFunctions.RoundEnd("Blue has won!")
  60.         else
  61.             GlobalFunctions.RoundEnd("The host has ended this round early.")
  62.         end
  63.         for i,v in pairs(Players:GetGetPlayers()) do
  64.             v.Team = game.Teams.Spectators
  65.             v:LoadCharacter()
  66.         end
  67.     ForceEnd = false
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement