Strange issue where the player's character gets deleted after jumping

I was going to make a simple module that puts your camera above your character and a few other things, but I ran into this weird issue.

The character seems to just get deleted or something after jumping.
Video:

Output:

The only way I was able to fix the issue was by commenting out the camera stuff. The code setting the cframe of the root has no impact somehow.

Not sure if I should upload this to some category as a bug report or if there’s something in my code I’m doing wrong.

local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local mouse = game.Players.LocalPlayer:GetMouse()

local offset = Vector3.new(0, 25, 0)

runService.RenderStepped:Connect(function(dt)
	local char  = game.Players.LocalPlayer.Character or nil
	if char then
		local root = char.HumanoidRootPart or nil
		if root then
			camera.CameraType = Enum.CameraType.Scriptable
			camera.CFrame = CFrame.new(root.Position+offset, root.Position)
			
			local mousePos = mouse.Hit.Position
			mousePos = Vector3.new(mousePos.X, root.Position.Y, mousePos.Z)
			
			print("results: ")
			print(root.Position or "nil")
			--print(mousePos or "nil")
			--print(CFrame.new(root.Position, mousePos))
			
			--root.CFrame = CFrame.new(root.Position, mousePos)
		end
	end
end)
1 Like

If there’s the case that the player’s HumanoidRootPart doesn’t need to be referenced over and over again, just reference it once in the global scope, avoiding issue.

In the other hand, replace char.HumanoidRootPart with char:FindFirstChild("HumanoidRootPart").

I think you’re confused. Me checking for the root part and character and making a variable each frame was just a lazy thing I did to test the thing quicker. It has absolutely nothing to do with the bug I’ve encountered here.

It’s probably something about when you are starting to freefall. I still cannot identify the issue except animations or something else. It is most likely a bug with the camera and jumping? I don’t really know.

Try starting from a height and freefalling and see if the issue is replicated through that way.

Ok, after some more testing it seems to be that when the camera script is enabled, any unanchored parts get deleted when moving above a certain height. I moved the baseplate up 10 studs and the character seems to get deleted as soon as it reaches the state of falling. And I also has an unanchored wedge which got deleted after the humanoid was walking over it and got deleted.

That’s super weird. That is indeed the only script that exists, correct?

I suspect it is either something about the object’s being hit with an extremely high velociy causing everything to delete themselves or something else. I’m not quite exactly sure, since this is most likely physics-based issue if you mentioned that a loose wedge also disappeared along with the character.

Well, in one of the tests the wedge disappeared after the humanoid, but I haven’t been able to replicate it.

I have no clue why this is happening, but I believe its the movement system choking up on camera relative movement somehow and flinging you into oblivion, perhaps a divide by 0 or something. I’ve fixed this by just doing:
camera.CFrame = CFrame.new(root.Position+offset) * CFrame.Angles(math.rad(-90), 0, 0)

1 Like

Thanks for the idea, I’m not sure if you’ve already fixed it but I’ll try out your solution later today!