Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = Instance.new("Message")
- m.Text = "Welcome to the Sword Fighting Tournament!"
- local eventrunning = false
- local deb = false
- function onChatted(msg, recipient, speaker)
- local source = string.lower(speaker.Name)
- msg = string.lower(msg)
- if (msg == "spectate") then
- speaker.Status.Value = 0
- local n = Instance.new("Message")
- n.Parent = speaker
- n.Text = "Now spectating."
- wait(1.5)
- n:remove()
- end
- if (msg == "play") then
- speaker.Status.Value = 1
- local n = Instance.new("Message")
- n.Parent = speaker
- n.Text = "Let the duel begin!"
- wait(1.5)
- n:remove()
- end
- if (msg == "start") and (deb == false) then
- local players = game.Players:getChildren()
- local competitors = 0
- for i = 1, #players do
- if players[i].Character ~= nil then
- if players[i].Status.Value == 1 then
- competitors = competitors + 1
- end
- end
- end
- ---We have to make this a COMPETITION. Not a "sit here, get points" place.
- if competitors >= 2 then
- deb = true
- wait(1)
- m.Parent = game.Workspace
- wait(3)
- m.Text = "Let the battles begin!"
- wait(1)
- ---First event down, now on to Fencing.-------------------------------------
- local players = game.Players:getChildren()
- local remaining = {}
- for i = 1, #players do
- if players[i].Character ~= nil then
- if players[i].Status.Value == 1 then
- players[i].Character.Humanoid.Jump = true
- wait(0.1)
- players[i].Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
- local fr = Instance.new("IntValue")
- fr.Name = "FencingRound"
- fr.Value = 1
- fr.Parent = players[i].Character
- local sword = game.Lighting.LinkedSword:clone()
- sword.Parent = players[i].Backpack
- local ff = Instance.new("ForceField")
- ff.Parent = players[i].Character
- table.insert(remaining, players[i])
- end
- end
- end
- wait(2)
- m.Parent = nil
- if #remaining >= 2 then eventrunning = true end
- local round = 1
- for i = 1, #remaining do
- print(remaining[i])
- end
- ---------------------------------------------------------------(120 lines)------------Fencing Event Script.
- while eventrunning do
- ------------------------------------------------------------------------Begin A/B combat.
- if #remaining >= 2 then
- local a = remaining[math.random(1, #remaining)]
- local b = remaining[math.random(1, #remaining)]
- while a == b do
- b = remaining[math.random(1, #remaining)]
- wait(0.1)
- end
- a.Character.Humanoid.Jump = true
- b.Character.Humanoid.Jump = true
- wait(0.1)
- a.Character:MoveTo(game.Workspace.SwordFightA.Position)
- b.Character:MoveTo(game.Workspace.SwordFightB.Position)
- if a.Character:findFirstChild("ForceField") ~= nil then
- a.Character:findFirstChild("ForceField"):remove()
- end
- if b.Character:findFirstChild("ForceField") ~= nil then
- b.Character:findFirstChild("ForceField"):remove()
- end
- local c = a.Character.Humanoid.Health*b.Character.Humanoid.Health
- print(c)
- while c ~= 0 do
- if a.Character ~= nil and b.Character ~= nil then
- c = a.Character.Humanoid.Health*b.Character.Humanoid.Health
- elseif (a.Character == nil or b.Character == nil) then
- wait(1.3)
- c = 0
- end
- wait(1.3)
- end
- if a.Character ~= nil then
- if a.Character.Humanoid.Health ~= 0 and a.Character:findFirstChild("FencingRound") ~= nil then
- a.leaderstats.Points.Value = a.leaderstats.Points.Value + a.Character.FencingRound.Value*10
- a.Character.FencingRound.Value = a.Character.FencingRound.Value + 1
- m.Text = "" .. a.Name .. " has won the duel!"
- m.Parent = game.Workspace
- wait(2.5)
- a.Character.Humanoid.Jump = true
- a.Character.Humanoid.Health = 100
- wait(0.5)
- local ff = Instance.new("ForceField")
- ff.Parent = a.Character
- a.Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
- m.Parent = nil
- end
- end
- if b.Character ~= nil then
- if b.Character.Humanoid.Health ~= 0 and b.Character:findFirstChild("FencingRound") ~= nil then
- b.leaderstats.Points.Value = b.leaderstats.Points.Value + b.Character.FencingRound.Value*10
- b.Character.FencingRound.Value = b.Character.FencingRound.Value + 1
- m.Text = "" .. b.Name .. " has won the duel!"
- m.Parent = game.Workspace
- wait(2.5)
- b.Character.Humanoid.Jump = true
- b.Character.Humanoid.Health = 100
- wait(0.5)
- local ff = Instance.new("ForceField")
- ff.Parent = b.Character
- b.Character:MoveTo(game.Workspace:findFirstChild("Viewing Booth").Position + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10)))
- m.Parent = nil
- end
- end
- end
- -------------------------------------------------------------------------End A/B combat
- print("Checking...")
- wait(3.1) --To make sure we get "FencingRound" out of the dead player...
- eventrunning = false
- remaining = {}
- for i = 1, #players do
- if players[i].Character ~= nil then
- if players[i].Character:findFirstChild("FencingRound") ~= nil then
- if players[i].Character.FencingRound.Value == round then
- table.insert(remaining, players[i])
- end
- end
- end
- end
- ----------To check remaining players.
- if #remaining >= 2 then
- print("2+ players remain.")
- eventrunning = true
- elseif #remaining == 1 then
- print("1 player remains...checking for others.")
- for i = 1, #players do
- if players[i].Character ~= nil then
- if players[i].Character:findFirstChild("FencingRound") ~= nil then
- if players[i].Character.FencingRound.Value == round + 1 then
- remaining[1].Character.FencingRound.Value = round + 1
- round = remaining[1].Character.FencingRound.Value
- table.insert(remaining, players[i])
- eventrunning = true
- end
- end
- end
- end
- if eventrunning == false then
- m.Text = "" .. remaining[1].Name .. " has won the Fencing Tournament!"
- m.Parent = game.Workspace
- remaining[1].leaderstats.Points.Value = remaining[1].leaderstats.Points.Value + 50
- remaining[1].Character:BreakJoints()
- wait(3)
- m.Parent = nil
- end
- elseif #remaining == 0 then
- print("Must not be any players left at this level...checking next round")
- for i = 1, #players do
- if players[i].Character ~= nil then
- if players[i].Character:findFirstChild("FencingRound") ~= nil then
- if players[i].Character.FencingRound.Value == round + 1 then
- table.insert(remaining, players[i])
- eventrunning = true
- end
- end
- end
- end
- if eventrunning == true then round = round + 1 end
- end----------End remaining check.
- ---Tournament runs until we have a definitive winner.
- end
- -------------------------------------------------------------------------------End Fencing Tournament Script.
- m.Text = "Congratulations to all who have participated!"
- m.Parent = game.Workspace
- wait(3)
- m.Parent = nil
- --------------------------------------------------------------------------------------------------------End of script.
- deb = false
- m.Text = "Welcome to the Sword Fighting Tournament!"
- end
- end
- end
- function onPlayerEntered(newPlayer)
- newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
- end
- game.Players.ChildAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement