The script (localscript) works as intended, but whenever I playtest, it outputs "Attempt to index nil with FindFirstChild, (only when looking at the sky.) This makes it next to impossible to read anything in the output, since it's being occupied by a gazillion of these errors.
Here's the script, hope someone can help:
`local player = game.Players.LocalPlayer local mouse = player:GetMouse()
mouse.Move:Connect (function() local target = mouse.Target
if target:FindFirstChild ("dex") then
target.dex.Enabled = true
if target.Transparency == 1 then
target.dex.Enabled = false
end
elseif target:FindFirstChild ("Berry") then
target.Berry.dex.Enabled = false
end
end)`
I'm a rookie at coding, so don't judge if the code's terrible ????

4 comments
Whatever target is, it's nil
flowery monkey is right. whatever target is, its nil or its an object that doesnt have the function :FindFirstChild()
Then how may I formulate the code differently as to prevent these errors??
You need to find what is causing target to be nil, where does it originate from? Trace back what could cause it to be nil.