Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = workspace.OfficialEvent -- this is the event to communicate between scripts
- local guievent = workspace.GUIEvent -- this even to communicate with GUIs
- local ucrtimer = workspace.UCREvent
- local raidertimer = workspace.RaiderEvent
- local objectiveevent = workspace.ObjectiveEvent
- local officialevent = workspace.Official
- local message = workspace.MessageToPlayers -- there is a script in a textlabel in a screengui, which receives the events
- local PointsService = game:GetService("PointsService")
- if(game.Workspace:findFirstChild("TimeMessage")~=nil) then -- just removing waste
- game.Workspace.TimeMessage:Destroy()
- end
- if(game.Workspace:findFirstChild("WinMessage")~=nil) then
- game.Workspace.WinMessage:Destroy()
- end
- --print("Flag Tester Loaded.")
- --// All the flags. 0 means DEFENDER holds it, 1 means ATTACKER holds it.
- flags =
- {
- [script.Parent:findFirstChild("Main Island")] = 0,
- [script.Parent:findFirstChild("UCR Island")] = 0,
- [script.Parent:findFirstChild("Raider Island")] = 0,
- [script.Parent:findFirstChild("Middle Island")] = 0
- }
- --h = Instance.new("Hint",workspace)
- --h.Name = "TimeMessage"
- m = Instance.new("Message",workspace)
- m.Name = "WinMessage"
- control = 0 -- 0 means raiders have no flags, 1 means one, etc. You have to have 2 flags to be gaining points
- dwintime = 4000 -- 1 and a half hours (90 minutes)
- rwintime = 1700 -- 30 minutes
- time = 0 -- raider timer, i.e. time with 2+ flags
- elapsed = 0 -- defender timer, i.e. total time for game
- ENDGAME = false -- basically if win conditions are met it stops the script
- numraiders = 0 -- number of raiders
- numdefenders = 0 -- number of defenders (ally + us)
- raidstarted = false
- count = 0
- function Update(cond)
- if cond == 0 then
- ucrtimer:Fire(elapsed)
- raidertimer:Fire(time)
- elseif cond == 1 then
- ENDGAME = true
- for i,v in pairs(game.Players:GetChildren()) do
- if v.TeamColor == game.Teams.Whites.TeamColor then
- v.leaderstats.Cash.Value = v.leaderstats.Cash.Value+2500
- PointsService:AwardPoints(v.userId, 2500)
- end
- end
- m.Text = ("Whites have successfully raided ORIION!")
- wait(15)
- time = 0
- elapsed = 0
- ENDGAME = false
- raidstarted = false
- --kickRaiders()
- wait(10)
- elseif cond == 2 then
- ENDGAME = true
- for i,v in pairs(game.Players:GetChildren()) do
- if v.TeamColor == game.Teams.Reds.TeamColor then
- v.leaderstats.Cash.Value = v.leaderstats.Cash.Value+2500
- PointsService:AwardPoints(v.userId, 2500)
- end
- end
- m.Text = ("Reds have successfully defended ORIION!")
- wait(15)
- time = 0
- elapsed = 0
- ENDGAME = false
- raidstarted = false
- m.Text = ""
- --kickRaiders()
- wait(10)
- end
- end
- function kickRaiders()
- for i,v in pairs(game.Players:GetChildren()) do
- if v.TeamColor == game.Teams.Raiders.TeamColor then
- script.LocalScript:Clone().Parent = v
- end
- end
- end
- for key, value in pairs(flags) do
- --print("hiiii")
- key.CurrentOwner.Changed:connect(function(owner)
- if (owner == BrickColor.New("Bright red")) and value == 1 then
- control = control - 1
- value = 0
- elseif (owner == BrickColor.new("Bright green")) and value == 1 then
- control = control - 1
- value = 0
- elseif (owner == BrickColor.White()) and value == 0 then
- control = control + 1
- value = 1
- end
- end)
- end
- repeat wait(1) until #(game.Players:GetChildren())>0
- while wait(1) do
- while ENDGAME == false do
- --wait(1)
- numraiders = 0 -- initalizes at 0
- numdefenders = 0 -- initalizes at 0
- if not raidstarted then
- for i,v in pairs(game.Players:GetChildren()) do
- if v.TeamColor == BrickColor.White() then
- numraiders = numraiders + 1 -- if there is an enemy, increase # of enemies
- elseif (v.TeamColor == BrickColor.new("Bright green") or v.TeamColor == BrickColor.new("Bright red")) then
- numdefenders = numdefenders + 1 -- if there is a defender, increase # of defenders
- end
- end
- if (numdefenders >= 2 and numraiders >= 2) then -- checks for required numbers of enemies and defenders
- message:Fire("RAID IS OFFICIAL")
- officialevent:Fire(1)
- wait(10)
- raidstarted = true
- end
- else
- count = count + 1
- if count>20 then
- count = 0
- for i,v in pairs(game.Players:GetChildren()) do
- if v.TeamColor == BrickColor.White() then
- numraiders = numraiders + 1 -- if there is an enemy, increase # of enemies
- elseif (v.TeamColor == BrickColor.new("Bright green") or v.TeamColor == BrickColor.new("Bright red")) then
- numdefenders = numdefenders + 1 -- if there is a defender, increase # of defenders
- end
- end
- if (numdefenders < 2 or numraiders < 2) then -- checks for required numbers of enemies and defenders
- message:Fire("RAID PAUSED. TOO FEW REDS OR WHITES")
- officialevent:Fire(2)
- wait(10)
- raidstarted = false
- end
- end
- elapsed = elapsed + 1
- if control == 0 then -- If the raiders have no flags
- if time > 1 then -- the raid timer will decrease by 2
- time = time - 2
- elseif time > 0 then
- time = time - 1 -- this is here so it doesn't go into the negatives accidentally
- end
- elseif control >= 2 then -- If the raiders have 2 or more flags
- time = time + 1 -- the raid timer will go up by 1
- end
- Update(0) -- updates hint at the top of the screen
- end
- if ((elapsed == dwintime) or (((elapsed + rwintime) - time) > dwintime)) then Update(2) -- defender win
- elseif time == rwintime then Update(1) -- raider win
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement