Advertisement
SpacecowboyHX

Untitled

Aug 3rd, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. local m = Instance.new("Message")
  2. m.Text = "Welcome to the Sword Fighting Tournament!"
  3. local eventrunning = false
  4. local deb = false
  5.  
  6. function onChatted(msg, recipient, speaker)
  7.  
  8. local source = string.lower(speaker.Name)
  9. msg = string.lower(msg)
  10.  
  11. if (msg == "spectate") then
  12. speaker.Status.Value = 0
  13. local n = Instance.new("Message")
  14. n.Parent = speaker
  15. n.Text = "Now spectating."
  16. wait(1.5)
  17. n:remove()
  18. end
  19. if (msg == "play") then
  20. speaker.Status.Value = 1
  21. local n = Instance.new("Message")
  22. n.Parent = speaker
  23. n.Text = "Let the duel begin!"
  24. wait(1.5)
  25. n:remove()
  26. end
  27.  
  28. if (msg == "start") and (deb == false) then
  29.  
  30. local players = game.Players:getChildren()
  31. local competitors = 0
  32. for i = 1, #players do
  33. if players[i].Character ~= nil then
  34. if players[i].Status.Value == 1 then
  35. competitors = competitors + 1
  36. end
  37. end
  38. end
  39.  
  40. ---We have to make this a COMPETITION. Not a "sit here, get points" place.
  41. if competitors >= 2 then
  42.  
  43. deb = true
  44.  
  45. wait(1)
  46. m.Parent = game.Workspace
  47. wait(3)
  48. m.Text = "Let the battles begin!"
  49. wait(1)
  50.  
  51. ---First event down, now on to Fencing.-------------------------------------
  52.  
  53. local players = game.Players:getChildren()
  54. local remaining = {}
  55.  
  56. for i = 1, #players do
  57. if players[i].Character ~= nil then
  58. if players[i].Status.Value == 1 then
  59. players[i].Character.Humanoid.Jump = true
  60. wait(0.1)
  61. players[i].Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
  62. local fr = Instance.new("IntValue")
  63. fr.Name = "FencingRound"
  64. fr.Value = 1
  65. fr.Parent = players[i].Character
  66. local sword = game.Lighting.LinkedSword:clone()
  67. sword.Parent = players[i].Backpack
  68. local ff = Instance.new("ForceField")
  69. ff.Parent = players[i].Character
  70. table.insert(remaining, players[i])
  71. end
  72. end
  73. end
  74.  
  75. wait(2)
  76. m.Parent = nil
  77.  
  78. if #remaining >= 2 then eventrunning = true end
  79.  
  80. local round = 1
  81. for i = 1, #remaining do
  82. print(remaining[i])
  83. end
  84.  
  85. ---------------------------------------------------------------(120 lines)------------Fencing Event Script.
  86. while eventrunning do
  87. ------------------------------------------------------------------------Begin A/B combat.
  88. if #remaining >= 2 then
  89. local a = remaining[math.random(1, #remaining)]
  90. local b = remaining[math.random(1, #remaining)]
  91. while a == b do
  92. b = remaining[math.random(1, #remaining)]
  93. wait(0.1)
  94. end
  95.  
  96. a.Character.Humanoid.Jump = true
  97. b.Character.Humanoid.Jump = true
  98. wait(0.1)
  99. a.Character:MoveTo(game.Workspace.SwordFightA.Position)
  100. b.Character:MoveTo(game.Workspace.SwordFightB.Position)
  101. if a.Character:findFirstChild("ForceField") ~= nil then
  102. a.Character:findFirstChild("ForceField"):remove()
  103. end
  104. if b.Character:findFirstChild("ForceField") ~= nil then
  105. b.Character:findFirstChild("ForceField"):remove()
  106. end
  107.  
  108. local c = a.Character.Humanoid.Health*b.Character.Humanoid.Health
  109. print(c)
  110.  
  111. while c ~= 0 do
  112. if a.Character ~= nil and b.Character ~= nil then
  113. c = a.Character.Humanoid.Health*b.Character.Humanoid.Health
  114. elseif (a.Character == nil or b.Character == nil) then
  115. wait(1.3)
  116. c = 0
  117. end
  118. wait(1.3)
  119. end
  120.  
  121. if a.Character ~= nil then
  122. if a.Character.Humanoid.Health ~= 0 and a.Character:findFirstChild("FencingRound") ~= nil then
  123. a.leaderstats.Points.Value = a.leaderstats.Points.Value + a.Character.FencingRound.Value*10
  124. a.Character.FencingRound.Value = a.Character.FencingRound.Value + 1
  125. m.Text = "" .. a.Name .. " has won the duel!"
  126. m.Parent = game.Workspace
  127. wait(2.5)
  128. a.Character.Humanoid.Jump = true
  129. a.Character.Humanoid.Health = 100
  130. wait(0.5)
  131. local ff = Instance.new("ForceField")
  132. ff.Parent = a.Character
  133. a.Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
  134. m.Parent = nil
  135. end
  136. end
  137. if b.Character ~= nil then
  138. if b.Character.Humanoid.Health ~= 0 and b.Character:findFirstChild("FencingRound") ~= nil then
  139. b.leaderstats.Points.Value = b.leaderstats.Points.Value + b.Character.FencingRound.Value*10
  140. b.Character.FencingRound.Value = b.Character.FencingRound.Value + 1
  141. m.Text = "" .. b.Name .. " has won the duel!"
  142. m.Parent = game.Workspace
  143. wait(2.5)
  144. b.Character.Humanoid.Jump = true
  145. b.Character.Humanoid.Health = 100
  146. wait(0.5)
  147. local ff = Instance.new("ForceField")
  148. ff.Parent = b.Character
  149. b.Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
  150. m.Parent = nil
  151. end
  152. end
  153.  
  154. end
  155. -------------------------------------------------------------------------End A/B combat
  156. print("Checking...")
  157. wait(3.1) --To make sure we get "FencingRound" out of the dead player...
  158. eventrunning = false
  159. remaining = {}
  160. for i = 1, #players do
  161. if players[i].Character ~= nil then
  162. if players[i].Character:findFirstChild("FencingRound") ~= nil then
  163. if players[i].Character.FencingRound.Value == round then
  164. table.insert(remaining, players[i])
  165. end
  166. end
  167. end
  168. end
  169. ----------To check remaining players.
  170. if #remaining >= 2 then
  171. print("2+ players remain.")
  172. eventrunning = true
  173.  
  174. elseif #remaining == 1 then
  175. print("1 player remains...checking for others.")
  176.  
  177. for i = 1, #players do
  178. if players[i].Character ~= nil then
  179. if players[i].Character:findFirstChild("FencingRound") ~= nil then
  180. if players[i].Character.FencingRound.Value == round + 1 then
  181. remaining[1].Character.FencingRound.Value = round + 1
  182. round = remaining[1].Character.FencingRound.Value
  183. table.insert(remaining, players[i])
  184. eventrunning = true
  185. end
  186. end
  187. end
  188. end
  189.  
  190. if eventrunning == false then
  191. m.Text = "" .. remaining[1].Name .. " has won the Fencing Tournament!"
  192. m.Parent = game.Workspace
  193. remaining[1].leaderstats.Points.Value = remaining[1].leaderstats.Points.Value + 50
  194. remaining[1].Character:BreakJoints()
  195. wait(3)
  196. m.Parent = nil
  197. end
  198.  
  199. elseif #remaining == 0 then
  200. print("Must not be any players left at this level...checking next round")
  201. for i = 1, #players do
  202. if players[i].Character ~= nil then
  203. if players[i].Character:findFirstChild("FencingRound") ~= nil then
  204. if players[i].Character.FencingRound.Value == round + 1 then
  205. table.insert(remaining, players[i])
  206. eventrunning = true
  207. end
  208. end
  209. end
  210. end
  211.  
  212. if eventrunning == true then round = round + 1 end
  213.  
  214. end----------End remaining check.
  215. ---Tournament runs until we have a definitive winner.
  216.  
  217. end
  218. -------------------------------------------------------------------------------End Fencing Tournament Script.
  219.  
  220. m.Text = "Congratulations to all who have participated!"
  221. m.Parent = game.Workspace
  222. wait(3)
  223. m.Parent = nil
  224.  
  225. --------------------------------------------------------------------------------------------------------End of script.
  226.  
  227. deb = false
  228. m.Text = "Welcome to the Sword Fighting Tournament!"
  229. end
  230. end
  231. end
  232.  
  233. function onPlayerEntered(newPlayer)
  234. newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
  235. end
  236.  
  237. game.Players.ChildAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement