Hi, so I recently got into raycasting for NPC reasons. I'm trying to create a part which will then show 100 studs in front of the part that I'm casting from. I want the ray to cast from the head of the NPC (I'm using look vector) and I want it to send a ray and create a part showing where the ray hit.
Code:
local ray = Ray.new(Vector3.new(Head.CFrame.LookVector),Vector3.new(Head.CFrame.LookVector * Vector3.new(0,0,-50))) local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent.Head}) local PartView = Instance.new("Part",workspace) PartView.Name = "RayCast" PartView.Anchored = true PartView.CanCollide = false PartView.Transparency = 0.5 PartView.Material = Enum.Material.Neon PartView.CFrame = CFrame.new(Vector3.new(Head.CFrame.LookVector),Vector3.new(0,0,-50)) game.Debris:AddItem(PartView,0.1) if hit then print(hit.Name) end end