Players randomly spawning too high up

I have a second life game pass in my game that allows players to have second chance to beat an obby level if they die.

Sometimes randomly players can spawn too high up from the spawn point (and I have a line of code that sets the HumanoidRootPart CFrame of the player back to spawn). That results in players getting stuck on top of the actual map itself.


Some players have even reported the gamepass breaking entirely, giving players unlimited lives.

playerConnections[player.Name] = player.CharacterAdded:Connect(function(character)
	player.CharacterAppearanceLoaded:Wait() -- Make sure that the character is fully loaded

	if dataFolder:FindFirstChild("Gamepasses"):FindFirstChild("SecondChance").Value == true then
		wait(0.1)

		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		humanoidRootPart.CFrame = loadedMap:FindFirstChild("SpawnPart").CFrame

		showLastLifeRE:FireClient(player)

		wait(0.5)
						
		playerConnections[player.Name]:Disconnect()
		playerConnections[player.Name] = player.CharacterAdded:Connect(function(character)
			player.CharacterAppearanceLoaded:Wait() -- Make sure that the character is fully loaded

			table.remove(players, i)
			player.Team = Teams.Lobby

			if findMapMusic(loadedMap.Name) ~= nil then
				MusicApi.stopMusic(player, findMapMusic(loadedMap.Name))
			end
			MusicApi.playLobbyMusic(player)

			playerConnections[player.Name]:Disconnect()
			playerConnections[player.Name] = nil
		end)
	else
		table.remove(players, i)
		player.Team = Teams.Lobby

		if findMapMusic(loadedMap.Name) ~= nil then
			MusicApi.stopMusic(player, findMapMusic(loadedMap.Name))
		end
		MusicApi.playLobbyMusic(player)

		playerConnections[player.Name]:Disconnect()
		playerConnections[player.Name] = nil
	end
end)

I have tried changing the code many many times, tried using humanoid.Died:Connect(), tried waiting and everything. It always just keeps happening and other members of my team want it to be fixed asap because in their opinion having a glitch like that in game makes the game bad and scares away new players.

Can you screenshot exactly where the SpawnPart is located?


Invisible cancollide false part right here


and the roof is this high up

Is there any unions or any invisible parts right near it that may interfere with collisions?

no

That’s exactly what he did, there’s nothing different about that.

1 Like

So just clarifying, does it teleport the player 100% of the time?

Maybe you accidentally duplicated a spawn with the same name an its above where the players getting teleported too?

image
no way

Maybe it has to do with you doing something with the players character

The code I just showed is the only thing that does anything with the player’s character.

Try this

playerConnections[player.Name] = player.CharacterAdded:Connect(function(character)
	player.CharacterAppearanceLoaded:Wait() -- Make sure that the character is fully loaded

	if dataFolder:FindFirstChild("Gamepasses"):FindFirstChild("SecondChance").Value == true then
		wait(0.1)

		local humanoidRootPart = player.character:WaitForChild("HumanoidRootPart")
		humanoidRootPart.CFrame = loadedMap:FindFirstChild("SpawnPart").CFrame

		showLastLifeRE:FireClient(player)

		wait(0.5)
						
		playerConnections[player.Name]:Disconnect()
		playerConnections[player.Name] = player.CharacterAdded:Connect(function(character)
			player.CharacterAppearanceLoaded:Wait() -- Make sure that the character is fully loaded

			table.remove(players, i)
			player.Team = Teams.Lobby

			if findMapMusic(loadedMap.Name) ~= nil then
				MusicApi.stopMusic(player, findMapMusic(loadedMap.Name))
			end
			MusicApi.playLobbyMusic(player)

			playerConnections[player.Name]:Disconnect()
			playerConnections[player.Name] = nil
		end)
	else
		table.remove(players, i)
		player.Team = Teams.Lobby

		if findMapMusic(loadedMap.Name) ~= nil then
			MusicApi.stopMusic(player, findMapMusic(loadedMap.Name))
		end
		MusicApi.playLobbyMusic(player)

		playerConnections[player.Name]:Disconnect()
		playerConnections[player.Name] = nil
	end
end)
2 Likes