Argument 1 missing or nil raycast

Raycast

local ray = workspace:Raycast(FirePos.Position,mouse.Hit.Position-FirePos.Position)			
				local hit = workspace:FindPartOnRay(ray)-- THIS LINE ERROR

image
image
image
image

Workspace:Raycast already returns a RaycastResult (not a Ray) with an Instance directing to the object it hit.

local raycast = workspace:Raycast(FirePos.Position,mouse.Hit.Position-FirePos.Position)	-- THIS LINE ERROR		
if raycast then -- `raycast` would be `nil` if the ray didn't hit anything
   local hit = raycast.Instance
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.