My main script that controls the GUI is in StarterPlayerScripts and it keeps yielding the code when i use WaitForChild to get basic stuff inside of PlayerGui:
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("MainMenu")
local TicketMachine = PlayerGui:WaitForChild("TicketMachine")
I suspect this is something involving the structure of my variables but Im unsure.
It’s a bit cheesy but i find that adding the line local character=Player.Character or Player.CharacterAdded:Wait() fixes it, it just makes the script wait till the character is loaded, sometimes it does that when everything takes too long to load so making the script wait until atleast the character is loaded solves that problem
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerGui
repeat task.wait()
PlayerGui = Player.PlayerGui
until PlayerGui ~= nil
local Gui
repeat task.wait()
Gui = PlayerGui:FindFirstChild("MainMenu")
until Gui ~= nil
local TicketMachine = PlayerGui:WaitForChild("TicketMachine")