Vaulting script raycasting issue

I am programming a vaulting system to vault over parts and im using raycasting to detect if the player can vault, but there is an issue with the raycasting and i cant find a way to fix it.

I am using 2 rays to detect if the player can vault, 1 coming out of the humanoid root part that goes 11 and 1 coming out of an attachment that is located 1 stud above the heads position and 0.5 studs behind the head going 11 studs in front of the head.

So if the ray coming out of the HRP is detecting a part and the ray that comes out of the head attachment is not detected then the player can vault.

But for some reason it will not work and it will not detect anything even if i am in front of a wall

image (4)

The problem is the head ray, the HRP ray is perfectly fine but i think the head ray is casting a ray in the wrong direction and i have no idea how to check.

here is the attachment and code for the head ray

image

-- variables used
local char = script.Parent
local head = char:WaitForChild("Head")

local headAttachment = Instance.new("Attachment")
headAttachment.Parent = head
headAttachment.CFrame = CFrame.new(0, 1, 1) * CFrame.Angles(math.rad(head.Rotation.X), math.rad(head.Rotation.Y), math.rad(head.Rotation.Z))

--the line of code i used to cast the head ray
workspace:Raycast(headAttachment.Position, head.CFrame.LookVector * 11, params)
1 Like

found the solution it was pretty simple uh sorry for posting this

1 Like