Wall Raycasting Problems

Alright, so I figured out since it’s 1 stud in front of the player the raycast might detect hats and stuff like that, but I’ve looped through that hats and put them on the ignore list but they dont seem to be getting ignored.

for i,v in pairs(char:GetChildren()) do
			if v:IsA("Accessory") or v:IsA("Hat") then
					test = v
		local climbRay = Ray.new(head.Position, head.CFrame.lookVector * 1)
		local hit, position, surface = game.Workspace:FindPartOnRayWithIgnoreList(climbRay, {humrp,test})

1 Like

The LookVector of a CFrame is relative to the CFrame, it is in object space (hence it is always 0 on two axes and 1 on one).

Since the ray constructor’s second argument takes a direction relative to the starting point of the ray, you’ll have to:

  1. First convert the LookVector into world space
  2. And then make it relative to the starting point (head.Position)
local worldLookVec = head.CFrame:VectorToWorldSpace(head.CFrame.LookVector) -- Convert to be relative to origin / world space
local direction = (worldLookVec - head.Position).Unit -- The vector B as relative to A is B-A
local climbRay = Ray.new(head.Position, direction)

That wasn’t the solution to the problem look at the edited post above

It seems like you are resetting the value of test every time you iterate over an accessory, which excludes the other accessories from the ignore list. My guess is that you need to make test a table that holds the humanoid root part and use table.add() to add each accessory, then pass that table into your raycast.

Alright sounds good I’ll try that.

Wait, but that’s already a table of the accessories though

I’m a bit confused here. Where is the table of accessories? test is only assigned one accessory at a time, so it looks like you’re only passing that and the hum root, instead of all accessories.

Maybe you could try using FindPartOnRay() and just pass the player’s character so that all of its descendants are being ignored, including the accessories.

Oh I fixed the problem, but the thing is now I need to get my player to rotate on different edges of the wall and it’s not working out for me, also the problem with my climbing mechanic is that depending on which surface of the part I raycast on it like inverses the controls its super weird