while wait() do
local Handle = script.Parent.Handle
local RayCastParamaeters = RaycastParams.new()
RayCastParamaeters.FilterDescendantsInstances = {}
RayCastParamaeters.FilterType = Enum.RaycastFilterType.Blacklist
local RayDirection = Handle.CFrame.LookVector * 10
local CastedRay = workspace:Raycast(Handle.Position, RayDirection, RayCastParamaeters)
if CastedRay then
if CastedRay.Instance.Name == "Wendigo" then
print(CastedRay.Instance.Name)
end
end
end
You’ll want to cast to the part you want to see if the tool can see. A part’s LookVector is a relative direction of the part that points forward.
function canSeePart(handle, targetPart)
local origin = handle.Position;
local direction = CFrame.new(origin, targetPart.Position).LookVector; --Creates a LookVector that faces the target part from the origin
direction *= 20; --Change 20 to the maxiumum distance you want to be able to raycast.
local RayCastParamaeters = RaycastParams.new()
RayCastParamaeters.FilterDescendantsInstances = {}
RayCastParamaeters.FilterType = Enum.RaycastFilterType.Blacklist
local result = workspace:Raycast(origin, direction, RayCastParamaeters);
return result and result.Instance == targetPart or false;
end
for this, is this supposed to be the specific part you want to raycast to see if the ray hits it? if so, how can the ray detect if it hits any type of part?