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!

2 comments
Changed isn't a thing for all objects in Lua -- only ROBLOX instances get it. If
_G.PlayerBallis just a variable you're controlling, it doesn't have aChanged. If it's a ObjectValue or StringValue, etc, then see Redbullusa's answerChanged actually works on _G.(Globals) as long as they aren't nil.