Attempt to index nil with 'IsA'

Im trying to make a gun shoot script, and this is what ive done so far:

(server script)

if hit:IsA('Humanoid') then
hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 10
end

hit is the object detected by the mouse.Target function in a seperate local script.

this works perfectly when i shoot a Basepart, but when i try shooting the sky, i get the error attempt to index nil with 'IsA'.

How do i fix this? all help is appreciated!

1 Like

If hit ~= nil then, but this code before the humanoid check code

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.