Hey everyone I made a round based system and was planning to use it for my game however once it was tested nothing was happening.. I have a string value that should tell the text label when the round will begin and end, who won the round and if everyone has died. It worked once now it isn't. can anyone help?

SCRIPT:

local players = game:GetService("Players")

local inMatch = game.ReplicatedStorage:WaitForChild("InMatch")
local status = game.ReplicatedStorage:WaitForChild("Status")

local lobbyTeam = game.Teams.Lobby
local orangeSpawns = workspace:WaitForChild("OrangeSpawns")
local purpleSpawns = workspace:WaitForChild("PurpleSpawns")

local roundLength = 150
local intermissionLength = 25

local ServerSword = game:GetService("ServerStorage"):WaitForChild("LinkedSword")
local swordClone = ServerSword:Clone()

------------------------------------
--Main Match Script--
------------------------------------

inMatch.Changed:Connect(function()
	if inMatch.Value == true then
		for i,plrs in pairs(players:GetChildren()) do
			local hrps = {}
			
			local char = plrs.Character
			local hrp = char:WaitForChild("HumanoidRootPart")
			local hum = char:WaitForChild("Humanoid")
			
			table.insert(hrps, hrp)
			
			--hrp1 to 11--
			hrps[1].CFrame = purpleSpawns.PurpleSpawn1.CFrame
			hrps[3].CFrame = purpleSpawns.PurpleSpawn2.CFrame
			hrps[5].CFrame = purpleSpawns.PurpleSpawn3.CFrame
			hrps[7].CFrame = purpleSpawns.PurpleSpawn4.CFrame
			hrps[9].CFrame = purpleSpawns.PurpleSpawn5.CFrame

			--A part is touched to make them orange team, vice versa

			hrps[2].CFrame = orangeSpawns.OrangeSpawn1.CFrame
			hrps[4].CFrame = orangeSpawns.OrangeSpawn2.CFrame
			hrps[6].CFrame = orangeSpawns.OrangeSpawn3.CFrame
			hrps[8].CFrame = orangeSpawns.OrangeSpawn4.CFrame
			hrps[10].CFrame = orangeSpawns.OrangeSpawn5.CFrame
			
			if plrs.Team == game.Teams.Purple or plrs.Team == game.Teams.Orange then
				swordClone.Parent = plrs.Backpack
			end
				
			if hum.Health <= 0 then
				plrs.Team = lobbyTeam
			end			
		end
	end
end)


local function round()	
	while true do

		local requiredPlayers = 2
		local numOfPlrs = game.Players:GetChildren()

		repeat wait(1) status.Value = requiredPlayers.." players are needed to start a match.." until #numOfPlrs >= requiredPlayers

		inMatch.Value = false

		for i = intermissionLength, 0, -1 do
			status.Value = "Match will start in "..i.." seconds"
			wait(1)
		end
		
		inMatch.Value = true

		for i = roundLength, 0, -1 do
			status.Value = "Match will end in "..i.." seconds"

			local playing = {}

			for i, plr in pairs(game.Players:GetChildren()) do
				if plr.Team.Name == "Orange" or plr.Team.Name == "Purple" then
					table.insert(playing, plr.Name)
				end
			end

			if #playing <= 0 then
				status.Value = "Everyone Has Died"

				wait(3)
				break
			end
			
			if #playing == 1 then
				status.Value = playing[1].." Has Won!"

				for i, plr in pairs(game.Players:GetChildren()) do
					if playing[1] == plr.Name then
						plr.leaderstats.Wins.Value += 1
					end
				end
				wait(3)				
				break
			end
			wait(1)
		end
		wait(3)
	end
end

spawn(round)

1 comment

0

Play it and put the error message that the output said. Look for color red.