Character Teleporting After Death

Hello Everyone,
I wasn’t sure where else to put this post, so I figured here would be the closest match, sorry if it is incorrect.

Essentially, I have noticed that my player’s character in my game often teleports somewhere upon death, usually a random location. I am not sure and am clueless as to why this keeps happening.

I have checked every time where the character’s HumanoidRootPart is moved (when the character is teleported) via a script, yet not a single time does it occur when the player dies, only in certain events not related to the player’s death. if this is just some other bug, I would appreciate any feedback.

Below is a clip of this error occurring:

Also, if anyone knows why my spawn locations are sometimes not working and teleporting the player into the void, I would also appreciate that.

EDIT - This is the only code that executes whenever a player dies:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char.Humanoid.Died:Connect(function()

			-- We want to make sure we delete the Ready up button from the dead player's screen and remove them from the ready table
			-- If we do not do so, the player can glitch coins.

			player.PlayerGui:FindFirstChild("readyUp"):Destroy()

			debounces[player.Name] = false

			local index = table.find(readyPlayers, player.Name)

			if index then
				table.remove(readyPlayers, index)
			end

			-- We want to check if the player that died was the second to last player alive, to mark if the round should end or not.
			if GameOn.Value == true then
				if isTheGameOver() == true then
					GameOn.Value = false

					-- This elseif statement runs if the player resets while they are supposed to choose an obby.
				elseif isTheGameOver() == false and player.UserId == RecentWinnerId.Value and didNotChooseObbyYet.Value == true then
					obbyPlacer(player, easyObbyName, "Easy")
				else

				end
			end
		end)
	end)
end)
3 Likes

It is highly likely that this is just a roblox bug, but it’s best to try to disable the script with the .Died connection and test out if that solves the bug, If it doesn’t please do check the script for killing the humanoid via the .Touched event.

3 Likes

Nope. Does not fix the bug.

I am almost certain this is a Roblox bug. I have kept my script enabled. Even though I copied the same model and put it in the workspace, it still does not replicate the bug, so it’s not something with the Touched event.

The only way I can replicate this bug is by allowing normal gameplay to take place. However, even when I tried manually entering the functions in my Script that place the Obby’s model into the workspace (instead of letting events do their thing to place it), the bug did not replicate so I am lost on what’s the cause of this bug.

I am pretty sure I saw this bug happen before on a YouTube video though, so it might not be something on my end.

EDIT: Here is the Touched event script.

function onTouched(hit)
	local human = hit.Parent:FindFirstChildOfClass("Humanoid") 

	if human then
		human.Health = 0 
	end
end

for i, killbrick in pairs(script.Parent:GetChildren()) do
	if killbrick:IsA("Part") then
		killbrick.Touched:Connect(function(hit)
			onTouched(hit)
		end)
	end
end
1 Like

For me, I managed to prevent the bug (Roblox bug). Seems to be a problem whenever you edit the HumanoidRootPart’s position of a player, which does happen in my game prior to the clip of the death I showed earlier.

It’s related to the bug in this thread:

To fix the error, I instead used :PivotTo() for the Character models instead of adjusting the player’s HumanoidRootPart.Position

3 Likes

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