Parkour ledge Climb not working as inteaded

I’m making a ledge grab mechanic in Roblox using raycasting, all is working well except the wall strafing
Here’s a video that kind of explains all the problems
robloxapp-20220326-0231044.wmv (3.4 MB)

Also Red/Yellow dots “Should show the origin” and Blue/Teal dot “Should show the direction”, and green is a success indicator for if it hits a block so the player can move left/right.

The problem is that the rays don’t seem to be going in the right direction for some reason. In the video
you can see that on one side the strafing works but on the other side it doesn’t, and on the high wall the green dot is way off to the left of the player’s origin and direction dots.

Here my raycasting code

function StrafL()
	local Origin = RootPart.Position + RootPart.CFrame.RightVector * -4.5
	local Direction = RootPart.Position + (RootPart.CFrame.LookVector * 1.5) + RootPart.CFrame.RightVector * -4.5
	VisualBlock(Origin,Color3.new(1, 0, 0),0.1)
	VisualBlock(Direction,Color3.new(0, 1, 0.635294),0.1)
	
	local Parms = RaycastParams.new()
	Parms.FilterDescendantsInstances = Character:GetDescendants()
	Parms.FilterType = Enum.RaycastFilterType.Blacklist
	local LedgeCheck = workspace:Raycast(Origin, Direction, Parms)
	if LedgeCheck then
		VisualBlock(LedgeCheck.Position,Color3.new(0.0666667, 1, 0),0.3)
	end
	
	if LedgeCheck and Holding == true then
		local Velo = Instance.new("BodyVelocity",RootPart)
		RootPart.Anchored = false
		Velo.MaxForce = Vector3.new(1,1,1) * math.huge
		Velo.Velocity = RootPart.CFrame.RightVector * -5
		HoldA:Stop() StrafLeftA:Play()
		game.Debris:AddItem(Velo,.75)
		Holding = false
		wait(.75)
		RootPart.Anchored = true
		HoldA:Play()
		Holding = true
	end
end
function StrafR()
	local Origin = RootPart.Position + RootPart.CFrame.RightVector * 4.5
	local Direction = RootPart.Position + (RootPart.CFrame.LookVector * 1.5) + RootPart.CFrame.RightVector * 4.5
	VisualBlock(Origin,Color3.new(1, 0.85098, 0),0.1)
	VisualBlock(Direction,Color3.new(0, 0.180392, 1),0.1)
	
	local Parms = RaycastParams.new()
	Parms.FilterDescendantsInstances = Character:GetDescendants()
	Parms.FilterType = Enum.RaycastFilterType.Blacklist
	local LedgeCheck = workspace:Raycast(Origin, Direction, Parms)
	if LedgeCheck then
		VisualBlock(LedgeCheck.Position,Color3.new(0.0666667, 1, 0),0.3)
	end
	
	if LedgeCheck and Holding == true then
		local Velo = Instance.new("BodyVelocity",RootPart)
		RootPart.Anchored = false
		Velo.MaxForce = Vector3.new(1,1,1) * math.huge
		Velo.Velocity = RootPart.CFrame.RightVector * 5
		HoldA:Stop() StrafRightA:Play()
		game.Debris:AddItem(Velo,.75)
		Holding = false
		wait(.75)
		RootPart.Anchored = true
		HoldA:Play()
		Holding = true
	end
end

StrafR, Makes the player try to strafe right: this function is fired when the player presses “E”
StrafL, Makes the player try to strafe Left: this function is fired when the player presses “Q”

I can’t really find a way to fix this, help would be very appreciated!

2 Likes

Just uping this, still no results. all my raycast don’t even follow the instructions i give them

I’ve fixed this problem. The problem is that im using vector3 positions and not directions as the target for the ray. So replacing this line

local Direction = RootPart.Position + (RootPart.CFrame.LookVector * 1.5) + RootPart.CFrame.RightVector * -4.5

with this line

local Target = RootPart.Position + (RootPart.CFrame.LookVector * 1.5) + (RootPart.CFrame.RightVector * 3.5)
	local Direction = Target - Origin

It fixes the direction the ray is casted, towards the direction and not some random location i sent with the first code

1 Like