local player = game.Players.LocalPlayer
local gui = player:WaitForChild(“PlayerGui”):WaitForChild(“MainUI”)
Prevents errors if the object hasn’t loaded yet
player.PlayerGui.MainUI can break if it doesn’t exist immediately
Why? Roblox loads assets more efficiently—WaitForChild() makes your script wait until the object is there.