repeat wait() until _G.PlayerBall ~= nil _G.PlayerBall.Changed:connect(function() if _G.PlayerBall ~= nil then Ball = _G.PlayerBall elseif _G.PlayerBall == nil then Ball = nil end end)
On line 2 it errors because I have _G.PlayerBall as a nil value every once in a while on purpose. Is there a way to overlook this so that it runs and doesn't error?
Thank you for your help!
The .Changed event only fires if the property of that object changes, not the existence of the object itself. Rather than doing the latter, try and see if the property that was changed is the Parent. Then see if the Parent of the object is nil.
-- Now that I think about it, this is pretty irrelevant to your question. This only applies if the object is not nil, but the Parent of it is. _G.PlayerBall.Changed:connect(function(property) if property == "Parent" then if not _G.PlayerBall.Parent then Ball = nil else Ball = _G.PlayerBall end end end) -- If the script still errors, then this most likely does not apply to you. Check out the links below if that happens.
Now, regarding deflection of errors, check out these links: