Help with ledge moving system

I’m currently making some parkour mechanics and stumbled upon this problem with ledge mechanics
What I want to do is make the player able to move while grabbing on a ledge, the grabbing works fine, but the moving has some problem, the player started to rotate the wrong direction (it’s moving in the correct way)
You can have a look at the issue here: https://gyazo.com/ff5aed095c2a645fd28e807752aaf2de

Here’s the code that I use to make the player move while hanging (Currently I have only made the player moves to the left using the A key)

        local rayLeft = Ray.new(hrp.CFrame.p, hrp.CFrame.lookVector * 3)

		local part, pos, normal = workspace:FindPartOnRay(rayLeft, Character)

		local cross = Vector3.new(0, 1, 0):Cross(normal)


		if uis:IsKeyDown(Enum.KeyCode.A) then
			if not holding then return end
			hrp.Anchored = false
			local Vel = hrp.Vel
			local Gyro = hrp.Gyro
			Gyro.MaxTorque = Vector3.new(1 ,1 ,1) * math.huge
			Vel.MaxForce = Vector3.new(1, 1, 1) * math.huge
			Vel.Velocity = cross * -10
         end
1 Like

This is possible happening because when you create your body gyro, you’re not setting any CFrame, which means it will just rotate to a default value, which is making your player spin.

If you want the player to always look forward, you can try setting the Gyro’s CFrame to 1 stud in front of the player.

if uis:IsKeyDown(Enum.KeyCode.A) then
			if not holding then return end
			hrp.Anchored = false
			local Vel = hrp.Vel
			local Gyro = hrp.Gyro
            Gyro.CFrame = hrp.CFrame * CFrame.new(-1, 0, 0)
			Gyro.MaxTorque = Vector3.new(1 ,1 ,1) * math.huge
			Vel.MaxForce = Vector3.new(1, 1, 1) * math.huge
			Vel.Velocity = cross * -10
         end

If it still doesn’t work, try changing the -1 to a 1, or other values on the CFrame.new()

1 Like

Thank you!! It worked perfectly! I will go and learn more about body gyro now :stuck_out_tongue:

1 Like