BodyGyro Aligning Problem

So basically when I raycast to a wall, I need it to face the wall, i’ve tried using the 4th value returned in the ray to align my character but it doesn’t seem to be working, anyone have any idea how I can accomplish this?

My Code.

local climbRay = Ray.new(humrp.Position, humrp.CFrame.lookVector * 5)
		hit, pos, surfacenormal, material = game.Workspace:FindPartOnRayWithIgnoreList(climbRay, {humrp,head})
		lookAt = CFrame.new(Vector3.new(), -surfacenormal)
		surfaceUpVector = lookAt.UpVector
		surfaceRightVector = lookAt.RightVector
		local mag = (pos - head.Position).Magnitude
		if hit and not Climbing then
			
			local BodyGyro = Instance.new("BodyGyro")
			BodyGyro.CFrame = CFrame.new(Vector3.new(), -surfacenormal)
			BodyGyro.MaxTorque = Vector3.new(0,0,0)
			BodyGyro.D = 0
			BodyGyro.Parent = humrp

Change this : BodyGyro.CFrame = CFrame.new(Vector3.new(), -surfacenormal)

to this:

BodyGyro.CFrame = CFrame.new(RootPart.Position, Pos)

1 Like

Alright let me try that quickly thanks for the reply!

Thanks it worked man, loved the help!

1 Like