Raycast
local ray = workspace:Raycast(FirePos.Position,mouse.Hit.Position-FirePos.Position)
local hit = workspace:FindPartOnRay(ray)-- THIS LINE ERROR
Raycast
local ray = workspace:Raycast(FirePos.Position,mouse.Hit.Position-FirePos.Position)
local hit = workspace:FindPartOnRay(ray)-- THIS LINE ERROR
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
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.