Script not working

I have tried countless times to fix this one function; and it just doesn’t want to work. After they are teleported, if I try to move one client, it doesn’t update on the other client. And even when it does update for both clients, the round won’t start back up again. It says the player that died is missing from the table.

PLEASE HELP ME

here is the script:

function NewRound(Player,Status,w)
	
	if table.find(PlayersTable,Player.Name) then
		
		Player = table.find(PlayersTable,Player.Name)
		
		if Player then
			if w:IsA("Part") then
				
				RedTeleportParts = ORedTeleportParts
				BlueTeleportParts = OBlueTeleportParts
				
				if BlueNumber <= RedNumber then
					if BlueNumber < MaxPlayers then
						w.CFrame = BlueTeleportParts[1].CFrame

						table.remove(BlueTeleportParts,1)
					end
				else
					if RedNumber < MaxPlayers then
						w.CFrame = RedTeleportParts[1].CFrame

						table.remove(RedTeleportParts,1)
					end
				end
				
				Player.Character.Humanoid.WalkSpeed = 0
				
				Status.Value = "Get ready to fight!"

				wait(3)

				for i=3,1,-1 do
					Status.Value = "Round starting in "..i
					wait(1)
				end

				--GAME HAS SUCCESSFULLY STARTED!

				GameInProgress = true

				local Sword = game.ServerStorage.Swords.ClassicSword:Clone()
				Sword.Parent = Player.Backpack

				Player.Character.Humanoid.WalkSpeed = 16

				Status.Value = "Last team standing earns a point!"
				
				repeat wait() until BlueNumber == 0 or RedNumber == 0	
				
				--Round has ended.
				Status.Value = "Round ended!"
				Sword:Destroy()
				
				wait(5)
				
				if BlueNumber == 0 then
					RedPoints += 1
				elseif RedNumber == 0 then
					BluePoints += 1
				end
				
				if RedNumber ~= PointsToWin and BlueNumber ~= PointsToWin then
					NewRound()
				end
			end
		else
			warn("Player is nil!")
		end
	end
end
1 Like

Can you give more info> is this script on the server or client? Is there any scripts linked to this one?? Is there any errors?

1 Like

So far I see you use table.find() and that gives you the int value of the item you’re finding. Use this instead: PlayersTable[table.find(PlayersTable, Player.Name)]. (You set the plr twice so after your first if statement if I’m correct player.character…Humanoid.Walkspeed… is actually the int not plr.

1 Like

I’m not exactly sure why you’d set the player = player.name…int value. Maybe just remove that? I don’t see it used anywhere in the code. Only referring to player as the instance not the int.

1 Like

Thank you so much for all your help! I will be sure to check these when I can. Thank you again!