Scripting rounds problem

recently i wanted to make a sword fighting game with rounds as a starter, so i watched a tutorial on how to make the rounds system, but there is a problem

local intermission = 10
local RoundLength = 15

local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status

local PlayingTeam = game.Teams.Playing
local LobbyTeam = game.Teams.Lobby

InRound.Changed:Connect(function()
	if InRound.Value == true then

		for i, plr in pairs(game.Players:GetPlayers()) do --start round

			local char = plr.Character
			local HumanRoot = char:WaitForChild("HumanoidRootPart")



			HumanRoot:PivotTo(game.Workspace.MapSpawn.CFrame)
			
			plr.Team = PlayingTeam
			
			char:WaitForChild("Humanoid").Died:Connect(function()
				
				plr.Team = LobbyTeam
			end)
		end
	else
		for i, plr in pairs(game.Players:GetPlayers()) do --end round

			local char = plr.Character
			local HumanRoot = char:WaitForChild("HumanoidRootPart")



			HumanRoot:PivotTo(game.Workspace.Lobby.LobbySpawn.CFrame)
			
			plr.Team = LobbyTeam
		end
	end
end)

local function round()

	while true do
		InRound.Value = false
		for i = intermission, 0, -1 do

			Status.Value = "Game starts in" ..i.. "Seconds"

			task.wait(1)
		end

		InRound.Value = true

		for i = RoundLength, 0, -1 do

			Status.Value = "Game ends in" ..i.. "Seconds"
			
			local Playing = {}
			
			for i, plr in pairs(game.Players:GetPlayers()) do
				if plr.Team == "Playing" then
					table.insert(Playing, plr.Name)
				end
			end
			
			if #Playing == 0 then
				Status.Value = "Everyone Has Died!"
				task.wait(3)
				break
			end
			
			if #Playing == 1 then
				Status.Value = Playing[1].."Has Won!"
				task.wait(3)
				break
			end

			task.wait(1)
		end


	end
end

task.spawn(round)

i tried multiplayer too, it immediatly ends the round like that

Here you check if plr.Team is “Playing” but plr.Team doesnt check for names but for the team object itself. You should instead of plr.Team do if plr.Team.Name == "Playing" then or if plr.Team == LobbyTeam then

ahh thank you, do you think i should use this script to clone a sword into the players backpack too?

Yes you should it’s the easiest way here

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.