Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bin = script.Parent.Base
- owner = script.Parent.CurrentOwner
- distance = script.Parent.CaptureDistance.Value
- steps = script.Parent.StepsToBottom
- maxsteps = steps.Value
- a = script.Parent.Flag
- b = script.Parent.FlagDetail
- neutral = script.Parent.NeutralColor.Value
- attackingteam = nil
- defendingteam = nil
- script.Parent.FlagManager.Disabled = false
- players = {}
- for i,v in pairs(game.Players:GetPlayers()) do
- table.insert(players, v)
- end
- game.Players.PlayerAdded:connect(function(p) table.insert(players, p) end)
- function findTeamByColor(color)
- local returnee = ""
- for i,v in pairs(game.Teams:children()) do
- if v.TeamColor == color then
- returnee = v.Name
- break
- end
- end
- return returnee
- end
- function moveFlag(team, name, name2)
- if (team ~= owner.Value) and (owner.Value ~= neutral) then
- if steps.Value > 0 then
- a.CFrame = a.CFrame-Vector3.new(0,14/maxsteps,0)
- b.CFrame = b.CFrame-Vector3.new(0,14/maxsteps,0)
- steps.Value = steps.Value-1
- if steps.Value == 0 then
- attackingteam = team
- defendingteam = owner.Value
- owner.Value = neutral
- if m~=nil then m:Remove() end
- ------------------------
- player = game.Player.PlayerName
- if player.TeamColor ~= BrickColor.new("Medium Stone Grey") then return else end
- ---------------------------------
- m = Instance.new("Hint", workspace)
- m.Text = "The flag " ..script.Parent.Name.. ", owned by " ..name2.. ", is being captured by the " ..name.. "!"
- game:service("Debris"):AddItem(m, 5)
- end
- end
- elseif (team == owner.Value) and (owner.Value ~= neutral) then
- if steps.Value < maxsteps then
- a.CFrame = a.CFrame+Vector3.new(0,14/maxsteps,0)
- b.CFrame = b.CFrame+Vector3.new(0,14/maxsteps,0)
- steps.Value = steps.Value+1
- if steps.Value == maxsteps then
- owner.Value = team
- end
- end
- elseif (team ~= owner.Value) and (owner.Value == neutral) then
- if team == defendingteam then
- if steps.Value > 0 then
- a.CFrame = a.CFrame-Vector3.new(0,14/maxsteps,0)
- b.CFrame = b.CFrame-Vector3.new(0,14/maxsteps,0)
- steps.Value = steps.Value-1
- if steps.Value == 0 then
- if m~=nil then m:Remove() end
- m = Instance.new("Hint", workspace)
- m.Text = "The flag " ..script.Parent.Name.. " has been recovered from the " ..findTeamByColor(attackingteam).. " by the " ..name.. "!"
- game:service("Debris"):AddItem(m, 5)
- attackingteam = nil
- defendingteam = nil
- owner.Value = team
- end
- end
- else
- a.CFrame = a.CFrame+Vector3.new(0,14/maxsteps,0)
- b.CFrame = b.CFrame+Vector3.new(0,14/maxsteps,0)
- steps.Value = steps.Value+1
- if steps.Value == maxsteps then
- if m~=nil then m:Remove() end
- m = Instance.new("Hint", workspace)
- if defendingteam then
- m.Text = "The flag " ..script.Parent.Name.. " has been captured by the " ..name.. " from the " ..findTeamByColor(defendingteam).. "!"
- else
- m.Text = "The flag " ..script.Parent.Name.. " has been claimed by the " ..name.. "."
- end
- -------------------------------------------
- if name == "Raiders" then
- script.Parent.Timer.Disabled = false
- else
- script.Parent.Timer.Disabled = true
- for i,v in pairs(script.Parent.BrickTimer:GetChildren()) do --Gotta get that timer's name derp.
- v.Name = "Raiders do not have the flag."
- end
- end
- ------------------------------------------- Everything in this block is all that I did XD.
- game:service("Debris"):AddItem(m, 5)
- attackingteam = nil
- defendingteam = nil
- owner.Value = team
- end
- end
- end
- end
- while true do
- wait()
- for i,v in pairs(players) do
- if v.Character ~= nil then
- torso = v.Character:findFirstChild("Torso")
- if torso ~= nil then
- if (torso.Position-bin.Position).magnitude <= distance then
- if v.TeamColor ~= neutral then
- moveFlag(v.TeamColor, findTeamByColor(v.TeamColor), findTeamByColor(owner.Value))
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment