local function H(H,y)H.RespawnLocation=y H:LoadCharacter()local N=H.Character or H.CharacterAdded:Wait()local l=N:WaitForChild("\072\117\109\097\110\111\105\100")setPlayerCollisionGroup(H)l.Died:Connect(function()removeActivePlayer(H)respawnPlayerInLobby(H)end)end local function y(H)local y=H.Character if y:FindFirstChild("\087\101\097\112\111\110")then y.Weapon:Destroy()end if H.Backpack:FindFirstChild("\087\101\097\112\111\110")then H.Backpack.Weapon:Destroy()end end

local function readyPlayer(player, whichSpawn)
	-- Reminder: LoadCharacter recreates the player, so needs to happen at the start or else tools/listeners will be lost. 
	player.RespawnLocation = whichSpawn
	player:LoadCharacter()
	
	-- Adding in a wait to ensure player character has loaded
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")	

	setPlayerCollisionGroup(player)
		
	-- Checks if players die
	humanoid.Died:Connect(function()
		removeActivePlayer(player)
		respawnPlayerInLobby(player)
	end)
end

local function removePlayerWeapon(whichPlayer)
	local character = whichPlayer.Character

	-- If the player has it currently on their character
	if character:FindFirstChild("Weapon") then
		character.Weapon:Destroy()
	end
	-- If theplayer has the weapon in their backpack
	if whichPlayer.Backpack:FindFirstChild("Weapon") then
		whichPlayer.Backpack.Weapon:Destroy()
	end
end
