Character falls through floor after updating rootpart CFrame locally

The gun model in my game sets and locks the camera of the player to the third person. Wherever they look at, it updates the rotation of their humanoid root part.

However, for some players and not always, their character glitches and falls through the floor.

Here’s a video I took of it happening:

I am not sure how to fix this issue since I don’t understand why this bug seems to be occurring randomly. You sometimes have it and sometimes not. The problem is the player is falling through the cancollide floor only for their humanoid rootpart to keep them from falling in the void.

This is how I set the humanoid root part CFrame:

lookCFrame = CFrame.lookAt(humanoidRootPart.Position,camera.CFrame:PointToWorldSpace(Vector3.new(0,0,-100000)))
		humanoidRootPart.CFrame = CFrame.fromMatrix(humanoidRootPart.Position, lookCFrame.XVector, humanoidRootPart.CFrame.YVector)

If you have any feedback or clue as to what might be causing this and how to fix it, your help is appreciated. Thanks in advance!

EDIT
I noticed the character was glitching through the floor whenever the snowball hit the floor.

Once a snowball hits a part, I unanchor it and create a weld with the part it hit. I was putting the weld.Part0 to the snowball but after changing the weld.Part0 to the part it hit/the floor, the issue seems to not be reoccurring? Although, I am not sure about this since it would happen randomly and sometimes not. Also, I tween the snowball’s size to Vector3.new(). Not sure if that might have an effect with the glitch but don’t think so.

Also, I changed the way I rotate the character:

humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.CFrame.Position, humanoidRootPart.CFrame.Position + Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z))

Whenever the character dies, I disconnect the connection or else they’d be moving on the floor. Will update if I see this issue happening again after this patch.

EDIT
Changing the weld Part0 did not have any effect. The glitch still is happening.

Whenever the player is on that part and there’s a snowball welded to it, they fall through. I believe there’s a glitch with the welds causing this. My solution is to simply not weld the snowball to the part it hits unless that part is not anchored. I can confirm the problem actually has to do with welding a part to the part the player is standing on.

EDIT
The problem was fixed by not welding the snowball to an anchored part (The floor). I also used “Weld” and not “WeldConstraint” so it might have had an effect as it is older.

I would suggest to do something like the following post explained.

Basically they make use of the AutoRotate property, lock the Mouse in the Centre etc.
(Oh yeah they included a CameraOffset animation, which is quite nice.)

humanoid.CameraOffset = isShiftLockToggled and humanoid.CameraOffset:Lerp(Vector3.new(2), dt * 1.5) or humanoid.CameraOffset:Lerp(Vector3.new(), dt * 1.5)

As well as use a different way of rotating:

local x, y, z = camera.CFrame:ToOrientation();
humanoidRootPart.CFrame = humanoidRootPart.CFrame:Lerp(CFrame.new(humanoidRootPart.Position) * CFrame.Angles(0, y, 0), dt * 5)

I would say that the last part of the script could possibly fix it.

1 Like