Custom Character Controller freaking out

Hello devform i am creating a custom character controller, and i have ran into a problem, the character model starts freaking out when i move it to the ground

–video

–script that handles the control

function Controll.Update()
	if player.LocalPlayer.Character and player.LocalPlayer.Character.PlayerCapsul:FindFirstChild("bodyVelocity") then
		local bodyVelocity = player.LocalPlayer.Character.PlayerCapsul:FindFirstChild("bodyVelocity")
		
		local moveDirection = rightValue - leftValue
		if jumping and isOnGround() then
			player.LocalPlayer.Character.PlayerCapsul.bodyVelocity.Velocity += Vector3.new(moveDirection, 12, 0)
		end
		
		if not isOnGround() then
			player.LocalPlayer.Character.PlayerCapsul.bodyVelocity.Velocity -= Vector3.new(moveDirection, 2, 0)
		end
		
		player.LocalPlayer.Character.PlayerCapsul.Velocity = Vector3.new(moveDirection, 0, 0) * 20
		
	end
end

how could i possible fix this?

ok I’m not sure myself but I think the problem is because of the collision try adding a BodyAngularVelocity to prevent the CharacterCapsul from rotating everywhere and if there is a HumanoidRootPart try using a body velocity on the root part itself

1 Like

The possible thing is it still being pushed downwards once it has landed so it starts jittering around because it is trying to go pass the baseplate.