There's a value inside the ReplicatedStorage. I want to do a statement in order to get the value if it has loaded or not. But I want to ask if is it necessary or not? Here is the script:
local storage = game:GetService('ReplicatedStorage') local annstring = nil if not storage:FindFirstChild('AnnoucementString') then annstring = storage:WaitForChild('AnnoucementString') else annstring = storage.AnnoucementSring end
If it's not really necessary. Can I use this one instead? I'm just afraid of getting infinite yield.
local storage = game:GetService('ReplicatedStorage') local annstring = storage:WaitForChild('AnnoucementString')
Edit: If neither of my methods are incorrect or not efficient then is there any better suggestion to load the value?
The 2nd code is more efficient... The second parameter of WaitForChild() is the maximum amount of wait time before it moves on to the next line of code.
local annstring = storage:WaitForChild('AnnoucementString', 5)
In this example, if it does not find the child AnnouncementString after 5 seconds, it will move on to the next line of code and not wait there forever. Hope this helped!