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.
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.
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)
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 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