I have a program written where every time the mouse is moved, the script checks to see if the mouse is targeting certain blocks. The weird thing is, it will randomly throw and error saying the field Target is nil even though I'm checking to make sure it isn't! Here is a snippet of the code:
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Move:connect(function()
if mouse.Target ~= nil and mouse.Target == partToCheckFor then
--code
end
end)
(partToCheckFor is a place holder for a variable I used in my program)
Is there something I could do to make it not throw this error randomly, or is there at least a way I could work around it?

2 comments
That was just a typo on the website, my bad :)
Fixed