Players Teleported To The Spawnpoint Are Below The Map For The Server

In my game, you spawn in a spawnbox and is able to choose between 4 elements to play. After choosing an element, you are teleported to a random Spawnpoint in the map.

The issue is, there’s a small chance that, when you are teleported, your position for the server is about 20 studs below where you were supposed to be teleported to. This makes no sense because: for the character’s player who was teleported and the players who were in the game before they were teleported, they are in the correct position; while for the server and players who joined the game after they were teleported, they are in the wrong position.

It’s a small chance, but since it’s a fighting game, it’s very annoying when it happens because you have to fight an invisible player.

StreamingEnabled is disabled and the methods I’ve tried to teleport the character was using PivotTo() (current one being used), setting the HumanoidRootPart’s Position or its CFrame.

This post was made because genuinely no other posts have helped me. I have found posts with similar issues, but none of their solutions worked. I’ve had this problem for months already.

Code:

-- inside the class choosed event:
local spawns = workspace.Spawns:GetChildren()
local chosenSpawn = spawns[math.random(1, #spawns)]

character:PivotTo(CFrame.new(chosenSpawn.Position + Vector3.new(0, 5, 0)))

that code couldn’t cause them to spawn under the ground.

Check to make sure there are no spawn points under the ground.

When they do spawn underground, is it beneath a specific checkpoint? or does it happen with every checkpoint?

Are there any abilities that move the player (dodge, mega jump, etc.) That could possibly mess up the character’s position.
If there are, you could anchor the character, and then unanchor him .25 seconds after you spawn him.

Check to make sure there are no spawn points under the ground.

There really aren’t.

When they do spawn underground, is it beneath a specific checkpoint? or does it happen with every checkpoint?

Every checkpoint.

Are there any abilities that move the player (dodge, mega jump, etc.) That could possibly mess up the character’s position.

Nope! They aren’t able to use any abilities really before they’re loaded into the map, too. But I’ll try anchoring and unanchoring for now and check if players will still report the issue.

Thank you for replying.

Hmm.

If the spawnpoints are close to the ground, it’s possible that the player is glitching through the ground and falling through it.

It’s possible that if the players are far away from the spawn point, and suddenly teleport there, the local physics might have to load in there, which may take a small fraction of a second to load.

Are the players anchored when you spawn them?
Can i see a picture of the spawnpoint and the terrain around your spawn point?

If the spawnpoints are close to the ground, it’s possible that the player is glitching through the ground and falling through it.

I don’t believe so because even though the Spawnpoints are close to the ground, I teleport the characters some studs above it as you could see in the code. Also, if the player were to glitch on the ground, I still don’t see why it would only glitch for the server only.

It’s possible that if the players are far away from the spawn point, and suddenly teleport there, the local physics might have to load in there, which may take a small fraction of a second to load.

I’m aware about that, but for the client and some other clients as I’ve quoted in the post, the character is in the correct position. But maybe this could really be the issue.

Are the players anchored when you spawn them?

No. I’ll try doing that now and check if players still report the issue.

All of the Spawnpoints are above the ground and there aren’t any objects above them or around them. This is how all of them look like:
image

Hmm. I would try anchoring them, which should make it impossible for them to somehow get underground.

3 Likes

Hey. I’m bumping this again because sadly @PiercedMissile 's suggestion didn’t fix it.

Instead of using PivotTo maybe try MoveTo???

MoveTo is for walk. This is a teleport.

There are two MoveTo’s… One for models and one for humanoids. The one for the humanoid is the one that walks the character to the target position

Source:

Edit: Don’t offset it if you’re passing in the position because it will automatically calculate the offset for you. So it would be like this Mode:MoveTo(Position)

Oops, I’m sorry. Honestly I had no idea about the existence of a :MoveTo() method on Models, thank you. I’ll try to implement it in the game and come back in case it doesn’t fix it.

Hey! I’m back and bumping it again. Sadly @sonic_848 's suggestion did not fix the issue.

Finally months later I would like to set a solution (or more like work-around) to this probably engine bug.

Instead of directly teleporting the character from the lobby to the map, it’s interesting to use :LoadCharacter() instead right when you would usually teleport them. In this case, when the player’s class is chosen. Using the RespawnLocation property (see about it here) it’s possible to make the player’s character respawn at the given SpawnPoint after :LoadCharacter() is finally called.

Since in this work-around context the character’s position does not have to be set through changing Position, CFrame properties or calling a method that does so, the bug would simply not happen.

Edit:
I’ve realized a few weeks after this “solution” that the bug kept happening, just at a lower rate. I’m back again with a solution which I’ve been using for a good time and I’m sure it works because it fixes directly what the bug causes.

The reason to why this bug happens is still unknown, but it still does. On Studio test mode specifically, the bug happens at such a low rate that I was never able to check on Studio what exactly was happening, but a few weeks ago I was finally able to.

The RootJoint’s C0 is for absolutely no reason changed to a weird CFrame, causing to only the character’s members be about 100 studs below where the HumanoidRootPart actually is, while the HumanoidRootPart stays untouched.

The easiest solution I found was simply using a while-loop after the character is teleported to the map which sets the RootJoint’s C0 back to what it’s supposed to be. Example:

local rootJoint: Motor6D = rootPart.RootJoint
while character:IsDescendantOf(workspace) and humanoid.Health > 0 and rootPart.Parent == character do
    rootJoint.C0 = CFrame.new(Vector3.zero) * CFrame.fromOrientation(math.rad(-90), math.rad(-180), 0)
    task.wait(1)
end

At first I was just setting the RootJoint’s C0 back to that CFrame whenever the character was teleported, but that didn’t work even with a task.wait(5) before doing so. I’m not really happy with this solution, but it works and it’s okay to me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.