Here is my code in a tool with a handle
tool = script.Parent
handle = tool:WaitForChild("Handle")
tool.Equipped:Connect(function(mouse)
if mouse then
mouse.Icon = "rbxassetid://316279304"
tool.Activated:connect(function()
tool.Firing:Play()
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Part.CFrame.p).unit*300)
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {game:GetService("Players").LocalPlayer.Character,tool.Handle})
--if i use just FindPartOnRay and ignore only the player it will work and hit will not be a null value??
if hit then
print(hit.Name)
else
print("Error")
end
end)
end
end)

3 comments
Ah ok i actually found out its because im printing hit.name and not hit, which is weird because if i use FindPartOnRay and "print hit.name or hit" it works, but for FindPartOnRayWithIgnoreList you cannot print "hit.name", only hit. Well my problem is solved but i really want to understand why this is if anyone can explain to me
Line 6 is useless.
yeah forgot to remove it when im editing the code