How do I wait for a StringValue to load in?

I have a StringValue in each player for their language setting. It’s set to nothing at the start, but will be changed to whatever they had previously saved. How do I wait for it before starting the script?

I’m using “local playerLang = language.Value” to reference it

I mean if you know it’s the only property to be changed and it will be changed exactly once, you can do a StringValue.changed:Wait() which is like connecting to the .changed, but just yields instead. You could also connect to the .changed and trigger something else like a bindable you are waiting on once it becomes what you are expecting.

This is bad practice, it’s better if you first set the values of player data objects, then set their parent. That way, all you need to do is wait for them to be added(through WaitForChild) and you know that when you see them they have their expected value.

Not sure what you’re asking here…

repeat task.wait(0.33) until language.Value ~= ""
local playerLang = language.Value

This will stay in the loop until language.Value is not an empty string.

:GetPropertyChangedSignal(“Value”):Wait()

local PlayerLang = "English" -- Default until server loads data saved language.

language:GetPropertyChangedSignal("Value"):Connect(function()
 PlayerLang = language.Value -- When the property is changed update it here.
end)

Alternatively you could display nothing and when the server loads the player’s data fire the client through a remote event and directly tell the client what their language last was selected too.