Whenever my character dies, they seem to just teleport elsewhere

Whenever my character dies, they seem to just teleport elsewhere. I took a long time debugging and tried everything but nothing could fix it, it seems like the character keeps on teleporting into a random position on death is due to my teleportation system.


The code above does what it is meant to do properly by teleporting the player to a random spawn location but when the character dies in the game, the character would just teleport elsewhere instead of being in one spot.
Heres an example:


This is how i want the death to work, notice how the character doesnt teleport elsewhere and fall into the floor. This is also before the character got teleported into the game

This is what is happening whenever i reset which is not what i want to happen.

can you show the full code so we can help fix it?

I disabled every other code there is with just the teleportation code, the full code is just firing when a player click on a gui. This is a script not a local script.

Well we can’t see whats wrong if we don’t get the full code.

The thing that is wrong is the teleportation line. You can already see it.

does that line trigger on death, is it meant to?

No i said that i triggers when a gui is pressed???

Well the issue must be that its triggering on death which must mean there is a script doing this

fine here it is

script.Parent.Parent.Select.MouseButton1Click:Connect(function()
	local player =  script.Parent.Parent.Parent.Parent.Parent
	local listofspawns = game.ReplicatedStorage.spawns:GetChildren()
	player.Character:WaitForChild("HumanoidRootPart").Position = listofspawns[math.random(1,#listofspawns-1)].Position
end)

I disabled every other script, there is no other script doing this.

this line of code does not check if the player dies?

If you don’t want the player to die (never) you can try this: How can I make an unkillable humanoid? - #14 by unix_system

she wants the teleport system to work not that if she wanted infinite health she could just change the player health and max health

No this line of code is supposed to teleport the player into the game upon clicking the button.
It does it’s job but when a player dies it seems that the player gets teleported to a random positon. The issue is not with a code teleporting it elsewhere, the issue is with the player teleporting randomly upon death which is an unintended side effect of my teleport system.

I’m making a pvp game, this is not ideal.

Perhaps it’s a spawn point position, what you could do is make teams (even if each one for a player) & set their spawn location to a certain place

the spawn points are reference parts that are inside replicated storage

Ill implement ragdoll if worst comes to worst and i cant fix this

Hi, sorry for the extremely late reply, and apologies to everyone for bumping this.

I’m currently experiencing the same bug with my game right now, where the player teleports somewhere random once they die.

Did you manage to find out how to fix this bug? (or did you just use a ragdoll system instead)

I apologize for the late response myself, and I’m sure you’ve found a fix. I just ran into this issue myself and found that the problem was me using RootPart’s Position. Once I used RootPart’s CFrame to change the Player’s location I no longer had this issue

1 Like