Riley_Huntley

Untitled

Dec 1st, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. bin = script.Parent.Base
  2. owner = script.Parent.CurrentOwner
  3. distance = script.Parent.CaptureDistance.Value
  4. steps = script.Parent.StepsToBottom
  5. maxsteps = steps.Value
  6. a = script.Parent.Flag
  7. b = script.Parent.FlagDetail
  8. neutral = script.Parent.NeutralColor.Value
  9. attackingteam = nil
  10. defendingteam = nil
  11.  
  12. script.Parent.FlagManager.Disabled = false
  13.  
  14. players = {}
  15.  
  16. for i,v in pairs(game.Players:GetPlayers()) do
  17. table.insert(players, v)
  18. end
  19.  
  20. game.Players.PlayerAdded:connect(function(p) table.insert(players, p) end)
  21.  
  22. function findTeamByColor(color)
  23. local returnee = ""
  24. for i,v in pairs(game.Teams:children()) do
  25. if v.TeamColor == color then
  26. returnee = v.Name
  27. break
  28. end
  29. end
  30. return returnee
  31. end
  32.  
  33. function moveFlag(team, name, name2)
  34. if (team ~= owner.Value) and (owner.Value ~= neutral) then
  35. if steps.Value > 0 then
  36. a.CFrame = a.CFrame-Vector3.new(0,14/maxsteps,0)
  37. b.CFrame = b.CFrame-Vector3.new(0,14/maxsteps,0)
  38. steps.Value = steps.Value-1
  39. if steps.Value == 0 then
  40. attackingteam = team
  41. defendingteam = owner.Value
  42. owner.Value = neutral
  43. if m~=nil then m:Remove() end
  44. ------------------------
  45. player = game.Player.PlayerName
  46. if player.TeamColor ~= BrickColor.new("Medium Stone Grey") then return else end
  47. ---------------------------------
  48. m = Instance.new("Hint", workspace)
  49. m.Text = "The flag " ..script.Parent.Name.. ", owned by " ..name2.. ", is being captured by the " ..name.. "!"
  50. game:service("Debris"):AddItem(m, 5)
  51. end
  52. end
  53. elseif (team == owner.Value) and (owner.Value ~= neutral) then
  54. if steps.Value < maxsteps then
  55. a.CFrame = a.CFrame+Vector3.new(0,14/maxsteps,0)
  56. b.CFrame = b.CFrame+Vector3.new(0,14/maxsteps,0)
  57. steps.Value = steps.Value+1
  58. if steps.Value == maxsteps then
  59. owner.Value = team
  60. end
  61. end
  62. elseif (team ~= owner.Value) and (owner.Value == neutral) then
  63. if team == defendingteam then
  64. if steps.Value > 0 then
  65. a.CFrame = a.CFrame-Vector3.new(0,14/maxsteps,0)
  66. b.CFrame = b.CFrame-Vector3.new(0,14/maxsteps,0)
  67. steps.Value = steps.Value-1
  68. if steps.Value == 0 then
  69. if m~=nil then m:Remove() end
  70. m = Instance.new("Hint", workspace)
  71. m.Text = "The flag " ..script.Parent.Name.. " has been recovered from the " ..findTeamByColor(attackingteam).. " by the " ..name.. "!"
  72. game:service("Debris"):AddItem(m, 5)
  73. attackingteam = nil
  74. defendingteam = nil
  75. owner.Value = team
  76. end
  77. end
  78. else
  79. a.CFrame = a.CFrame+Vector3.new(0,14/maxsteps,0)
  80. b.CFrame = b.CFrame+Vector3.new(0,14/maxsteps,0)
  81. steps.Value = steps.Value+1
  82. if steps.Value == maxsteps then
  83. if m~=nil then m:Remove() end
  84. m = Instance.new("Hint", workspace)
  85. if defendingteam then
  86. m.Text = "The flag " ..script.Parent.Name.. " has been captured by the " ..name.. " from the " ..findTeamByColor(defendingteam).. "!"
  87. else
  88. m.Text = "The flag " ..script.Parent.Name.. " has been claimed by the " ..name.. "."
  89. end
  90. -------------------------------------------
  91. if name == "Raiders" then
  92. script.Parent.Timer.Disabled = false
  93. else
  94. script.Parent.Timer.Disabled = true
  95. for i,v in pairs(script.Parent.BrickTimer:GetChildren()) do --Gotta get that timer's name derp.
  96. v.Name = "Raiders do not have the flag."
  97. end
  98. end
  99. ------------------------------------------- Everything in this block is all that I did XD.
  100. game:service("Debris"):AddItem(m, 5)
  101. attackingteam = nil
  102. defendingteam = nil
  103. owner.Value = team
  104. end
  105. end
  106. end
  107. end
  108.  
  109. while true do
  110. wait()
  111. for i,v in pairs(players) do
  112. if v.Character ~= nil then
  113. torso = v.Character:findFirstChild("Torso")
  114. if torso ~= nil then
  115. if (torso.Position-bin.Position).magnitude <= distance then
  116. if v.TeamColor ~= neutral then
  117. moveFlag(v.TeamColor, findTeamByColor(v.TeamColor), findTeamByColor(owner.Value))
  118. end
  119. end
  120. end
  121. end
  122. end
  123. end
Advertisement
Add Comment
Please, Sign In to add comment