Climbscriptnot working

I am trying to code a climb script in roblox
using align position, align orientation and changing the cframe

local function heartBeatService(deltaTime)
	if canClimb ==  true then
		local keyPressed = game.UserInputService:GetKeysPressed()
		contains(keyPressed, Enum.KeyCode.W)
		if contains(keyPressed, Enum.KeyCode.W) == true then
			print("check1")
			hrp.CFrame = CFrame.new(hrp.CFrame.Position + Vector3.new(0, 3, 0)*deltaTime , hrp.CFrame.LookVector)
			--hrp.CFrame.Position + Vector3.new(1, 4, 1)
			local rayOrigin = Character.HumanoidRootPart.position
			local rayDirection = Character.HumanoidRootPart.CFrame.LookVector
			local raycastResult = workspace:Raycast(rayOrigin, rayDirection*10)
			if raycastResult == nil then
				canClimb = false
--check if facing wall
			end
		end
	end
end

The code above run every heartbeat

hrp.CFrame = CFrame.new(hrp.CFrame.Position + Vector3.new(0, 3, 0)*deltaTime , hrp.CFrame.LookVector)

This is all the movement functionality added no align position or align orientation

External Media

the link above is the vid issue for some reason mycframe.new just rotates the player and moves them up any idea why??? pls help

1 Like

mmmight wanna change that print rq… Not sure how well that’s going to fly here.

What is the logic of what you’re trying to do? From what I can see, you are checking to see if the player can climb, then to see if they’ve pressed W, and then raycasting. Wouldn’t it be better to raycast and THEN read player inputs?

ure right bruh. HASDHASHDSH cause imma need wasd