Issues with Raycast / size of the bricks?

I’m currently having issues with my Raycast getting the full size of a part? When trying to note if a Player is under a block, there seems to be an overlap where although the Player is under said part, the code recognises it as not being under it.
Is there a work around to this as it’s causing some issues.

RunService.RenderStepped:Connect(function()

for _,GetParts in pairs (workspace:GetDescendants()) do

if GetParts.Name == "CameraRay" then

table.insert(whiteListTb, GetParts)

local ray = Ray.new(Character:WaitForChild("HumanoidRootPart").CFrame.p, Character:WaitForChild("HumanoidRootPart").CFrame.p + Vector3.new(0, 50, 0))

local RayHit, NA = workspace:FindPartOnRayWithWhitelist(ray, whiteListTb)

if RayHit then

Camera.CFrame = CFrame.new(RayHit.Parent["CameraOrigin"].CFrame.p, RayHit.Parent["CameraDirection"].CFrame.p)

else end

else end

end

end)

I tried saying this in a prior post, but your ray is not defined correctly if you want it to go straight up. Unlike CFrames, the second direction parameter of the ray is already relative to the origin, so you don’t have to add the original position to it.
I would use this instead to replace your local ray:

local ray = Ray.new(Character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0,50,0))
3 Likes