I’m unsure whether to use WaitForChild(), FindFirstChild() or neither, here I have used WaitForChild() for every instance, because I’m worried that it won’t have loaded by the time the script has ran. So my question is is this necessary, is it better to be safe than sorry or is there a better way of doing it?
--declarations
local items = serverStorage:WaitForChild("GameObjects")
local data = items:WaitForChild("Data")
local floorBreak = data.FloorBreak:WaitForChild("Value")
local audio = items:WaitForChild("Audio")
local sounds = audio:WaitForChild("Sounds")
local songList = audio:WaitForChild("SongList")
local elevator = workspace:WaitForChild("Elevator")
local audioPart = elevator:WaitForChild("AudioPart")
local wall = elevator:WaitForChild("InvisibleWall")
local teleportB = elevator:WaitForChild("Floor")
local doorLeft = elevator:WaitForChild("DoorLeft")
local doorRight = elevator:WaitForChild("DoorRight")
local screen = elevator.FloorNumber.Screen:WaitForChild("Main")
local number1 = screen:WaitForChild("Number1")
local number2 = screen:WaitForChild("Number2")
local lobby = workspace:WaitForChild("Lobby")
local teleportA = lobby:WaitForChild("Teleport")
Being that it’s server sided code, you should be alright with FindFirstChild; because the server executes code after the environment is loaded. as Kampfkarren confirmed in a topic similar to such.
How ever if you have a script placing a part into workspace or such then you’d want to yield.
It is always wise to use :WaitForChild() from a local script rather than a server script, because things replicating from the server to the client takes time to load, whilst things already found in the server that don’t take time to load, called implict objects such as parts or building you have there when you uploaded your game to roblox and are always found loaded in the server whenever the player joins. In your script, considering that’s its a server script the :WaitForChild()'s aren’t needed, espacially if this script isn’t going to work straight away when the game starts.
Here is an article that explains when TO use and when NOT TO use :WaitForChild() and :FindFirstChild()