Teleporting player using humanoidrootpart acts weird

Hello. I’m working on the round system but I have a problem where the script will teleport the player under the baseplate and the player dies. I’ve first thought this is a problem with spawnpoints but is not, all spawnpoints are placed correctly so it must be a problem with code. I don’t know what’s wrong.

This is the function:

local function teleportPlayers() 
	
	local spawnpointFolder = currentlyLoadedMap.spawnpoints
	
	local newSword = ServerStorage.Weapons.Sword:Clone()
	newSword.Parent = Knight.Backpack

	local newStaff = ServerStorage.Weapons.Staff:Clone()
	newStaff.Parent = Wizard.Backpack
	
	for _,player in pairs(EveryOne) do
		if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			player.Character.HumanoidRootPart.CFrame = spawnpointFolder:GetChildren()[math.random(1,#spawnpointFolder:GetChildren())].CFrame
		else
			player:Kick("Invalid player character")
		end
	end
end

Thanks for any help

2 Likes
player.Character.HumanoidRootPart.CFrame = spawnpointFolder:GetChildren()[math.random(1,#spawnpointFolder:GetChildren())].CFrame * CFrame.new(0, 10, 0)

I’ve tried already, I made also new discovery this only happens when we teleport more than one player

Perhaps add a delay between teleporting players, because currently each player’s character model is being teleported into the others.

I’ve tried already too using task.wait() no effect

Yeah, I was thinking something more like task.wait(0.5) (30 frames) instead, task.wait() is a single frame. Alternatively move the spawn points slightly above the map (so they hover above the baseplate). You could also add a delay between cloning the map to workspace and teleporting all of the players to it to ensure that the map has loaded.

Oh yeah let me try I’ve did it with empty arguments

local spawnPoints = spawnpointFolder:GetChildren()

for i,player in pairs(EveryOne) do
		if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			player.Character.HumanoidRootPart.CFrame = spawnPoints[math.random(1,#spawnPoints)].CFrame
            table.remove(spawnPoints,i)
		else
			player:Kick("Invalid player character")
		end
	end

This prevents all players from spawning at the same spawn.

It did not help, I still dont know where is the issue

I can’t do that because there will be more players than 4 and if there would be more players than 4 spawnpoints the script could not spawn them anywhere

Create enough spawn points for each player.

Can’t really do that and I think that would not fix it, it’s error somewhere in code or idk

local spawnPoints = spawnpointFolder:GetChildren()
repeat task.wait()
until #spawnPoints == 4

Make the spawnpoint’s collisions enabled and add the above (providing there are 4 spawns).

I still that would not fix the issue I have

You mentioned players are falling through the map or spawning below the map?

They spawn below map fall and die, no idea why its happening

Are the spawn points CanCollide False?

Is the map by any chance position below a Y axis value of -500?

If the spawn points have collisions disabled and are unanchored they will fall through the map and be destroyed.

The map is at Y 223, spawn points have collisions disabled and they are anchored