I know I asked this before but now I have a different problem. I am trying to raycast from the head of the client to see where the player is looking towards. Heres my code:
while wait(1) do
local MyRayCast = Ray.new(Head.CFrame.p, Head.CFrame.LookVector * 100)
local part = workspace:FindPartOnRay(MyRayCast)
if part.Name == "NPCWall2" then
print("Yes")
elseif part.Name == "Wall2" then
print("Yessir")
end
end
Now, this all works perfectly fine but the problem I’m having is that one of the parts is too far away therefore the raycast doesnt reach it. How can I extend the raycast from the head in my code?
aka. I need to change up the Head.CFrame.LookVector * 100
I did something similar to this, but it was coming from the chest.
local hrp = player.Character.HumanoidRootPart
local ray = Ray.new(hrp.Position, hrp.CFrame.lookVector * 10)
local part, position = workspace:FindPartOnRayWithIgnoreList(ray, {hrp.Parent, tool})
This ray only went like 5 studs in front of the character but by change it from * 10 to say * 500 it would go much further.