Repeat wait() until not working for some players

I’m on mobile rn so I don’t have any screen shots or code

So basically I have a game that uses a repeat loop to wait until the saving system sets a boolean to true and it works… mostly

For some reason the repeat loop doesn’t even start on some devices. We tried putting a print() in the loop and nothing happened, it just kinda freezes.

We removed the loop and it worked but without the loop the code after could end up running before the saving system is ready.

-- This is an example Lua code block
repeat wait() until Loaded.Value == true
3 Likes

You can try the .changed event instead of constantly running the wait() - I don’t know if it will fix the issue but it’s more performance-friendly than running lots of wait()'s

1 Like

That could work yes.

But I wonder if this is a roblox bug.

1 Like

Could you please provide an example place once you’re on PC? I’d like to test this and help you figure out a solution

1 Like

It is basically a server script that sets a value to true and a local script in a gui that waits for it. Some things to know is auto spawn character is off as it is on the title screen (I will not have a pc for about 2 days

2 Likes
repeat task.wait() until Loaded.Value
Loaded.Changed:Connect(function(newVal)
	--do stuff when loaded changes
end)
local isLoaded = Loaded.Value

while (not isLoaded) do
	isLoaded = Loaded.Changed:Wait()
end

print("Loaded")
1 Like

I’m part of this project too! We’ve been having this issue for our Windows 10 App store users where the title screen (after I re-wrote the whole code), The game just has a black screen for instead of loading the title like normal.

The “Handler running…” Print shows the script runs the first start (Setting variables and whatnot before everything, Which is expected and runs just fine.
However, There’s a second print which we have that runs before the title screen code to tell us whether or not the title screen intro code is running or not, Which in most (if not all) cases on the Windows 10 App, It refuses to show us that print as if that code is not running.
image
This prints for normal ROBLOX clients on the client downloaded from the website, But from the windows 10 app it fails, There are also some isolated cases of certain mobile devices unable to load the title screen.


(Line 27 seems to be the one we’re having issues with, We’ve tried AlreadyPro & Limited_Unique’s solution and they did not work)

This is all the code we have for the handling of our saving system for the game, Which once we remove the repeat wait() until Loaded.Value == true, It works just fine on Windows 10 apps, But then other problems occur. The character selection screen doesn’t work right, You can’t click on the buttons to select a character, It doesn’t move the outline gradient to the new character to show which one you have selected, And doesn’t equip the character. This causes problems because any new player to our game cannot play the game if they can’t even load a character at all. (Yes, Even the default (your roblox avatar) doesn’t load for some odd reason).

Hope this helped give further explanation as to what’s going on!

1 Like

We have also put a print in the repeat loop and it never ran which is very strange

UPDATE: apparently this just happens to random people with no real connection… basically if the game does this it will always do it on that device and/or account. I don’t really understand what is going on at this point.

Update on this situation; This wasn’t a ROBLOX bug.
The problem was with our own saving system.

The problem was our game wasn’t making data for new users when they joined, And didn’t load custom outline colors, character colors, & world + effects data.
So therefore; The title screen failed to load a save that didn’t exist. (Which should be expected, How can you get something that isn’t there in the first place?)

Thanks to everyone who attempted to help us!