So I have this climbing mechanic and like it’s very buggy because depending on where the player is facing it will like mess up the whole thing not sure how to fix it heres a video of it.
if input.KeyCode == Enum.KeyCode.R and not Climbing then
local climbRay = Ray.new(humrp.Position, humrp.CFrame.lookVector * 5)
local hit, position, surface = game.Workspace:FindPartOnRayWithIgnoreList(climbRay, {humrp})
if hit then
print(surface)
Climbing = true
hum.PlatformStand = true
print("Climbing Enabled.")
local mag = (position - humrp.Position).Magnitude
local attachment = Instance.new("Attachment")
attachment.Parent = hit
attachment.WorldCFrame = (humrp.CFrame * CFrame.new(0,0,-mag))
attachment.Visible = true
attachment.Name = "WallClimb"
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Velocity = Vector3.new(0,0,0)
BodyVelocity.P = math.huge
BodyVelocity.Parent = humrp
BodyVelocity.Name = "Climb"
local BodyGyro = Instance.new("BodyGyro")
BodyGyro.CFrame = CFrame.new(Vector3.new()-surface)
BodyGyro.D = 0
BodyGyro.P = 0
BodyGyro.MaxTorque = Vector3.new(0,0,0)
BodyGyro.Parent = humrp
Debris:AddItem(BodyVelocity, 10)
Debris:AddItem(BodyGyro, 10)
wait(10)
Climbing = false
hum.PlatformStand = false
print(Climbing)
end
end
I’m not sure that works the same way. BodyGyro is usually for stabilization or making something maintain an orientation. You may not need to do any of that though. What exactly is the issue your having with your script, can you elaborate on that?
Basically I raycast to see if a wall is in front and the position is good and everything its just that bug where sometimes I go off the wall and if im not directly facing the wall it doesn allign me right
You can use that to figure out how to go about forcing the player using the CFrame to always directly face the wall. I don’t want to give you incorrect code but you can get the position and vector details you need using the wall and character CFrames.