Hello!

I have a Rounds-based game, when a player dies on the battle map, they're suppose to be transported back to the lobby while the remaining players fight. Instead, the player is sent back to the battle map. I think I've narrowed down my problem to either the Global Death Script or the Global Leave script. Any idea how to fix it? Thanks!

Global Death Script:

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild('Humanoid').Died:connect(function()
			local Update = {}
			for i, v in pairs(_G.gameplayers) do
				if v ~= player.Name then
					table.insert(Update, 1,v)
				end
				
			end
			_G.gameplayers = Update
		end)
	end)
end)

Global Leave Script:

game:GetService('Players').PlayerRemoving:connect(function(player)
	
			local Update = {}
			for i, v in pairs(_G.gameplayers) do
				if v ~= player.Name then
					table.insert(Update, 1,v)
				end
				
			end
			_G.gameplayers = Update
end)

2 comments

0

How come you use a variable for the list of player? You can get a list of the players by using ''game:GetService('Players'):GetPlayers()". Just wondering.

0

I used the same method for my rounds script, uniformity. :) The rounds script checks how many players are there, transports them to the battle map, then transports them back after time runs out. Was just easier.