I am trying to fire a raycast from the player’s head. This is the code I wrote.
It only fires in one direction rather than from where the player’s head is pointing.
local Character = script.Parent
function fireRay()
local IgnoreCharacter = Character
while wait(2) do
local Ray = Ray.new(Character.Head.CFrame.p,Vector3.new(100,0,0)) -- I believe its this part
local part = workspace:FindPartOnRay(Ray,IgnoreCharacter )
if part then
print(part.Name)
if part.Name == "RayTest" then
print("correct part!")
end
end
end
end
while true do
wait(1)
fireRay()
end