When I move my mouse into the sky I get a error on Mouse.Target.Name

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to get rid of this error

  2. What is the issue? Include screenshots / videos if possible!
    I’m getting this error when I aim in the sky
    Screenshot (194)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried saying if Mouse.Target.Name ~= nil then, but I’m not sure where to put this in the script
    Screenshot (196)

1 Like

When you aim at the sky the Target is nil, check mouse.Target before trying to get the name

if Mouse.Target and Mouse.Target.Name == "Wood" then
    --Code
else
    --Code
end