local function Raycast()
local Origin = Character.PrimaryPart.Position;
local Direction = (Part.Position + Part.CFrame.LookVector * 2 - Origin);
local Parameters = RaycastParams.new(); do
Parameters.FilterType = Enum.RaycastFilterType.Blacklist;
Parameters.FilterDescendantsInstances = { Character };
end
local Raycast = workspace:Raycast(Origin, Direction, Parameters);
if Raycast and Raycast.Instance then
MakeItOpen(false, tostring(Raycast));
else
MakeItOpen(true, "Raycast was not successfull!");
end
VisualizeRaycast(workspace.RaycastPart, workspace.RaycastPositionPart, Origin, Part.Position + Part.CFrame.LookVector * 2, Raycast);
return;
end
Your issue was that you were using raycasts wrong, the 2nd parameter is supposed to be the direction of where the ray goes, not the position of where the ray goes.