What is best way to ensure gui images in RepFirst load before script runs?

Well, I don’t seem to have write access in the “cool creations” section for feedback on this, so I’ll post here with some questions.


Occasionally, some of the parts won’t show up when the animation runs. For example, the boxes will move across the screen and the character won’t show. I haven’t been able to reproduce this reliably, so no video of that.

I have a setup script in ReplicatedFirst with a ScreenGui containing a hierarchy of frame and SelectionImageObjects (from Roundify plugin) as a child. In the middle of the hierarchy, I have a couple of local scripts that handle the animations. Generally speaking:

[Edit: Problem appears to be with images occasionally not loading into gui objects in RepFirst. Changed Title to reflect actual issue.]

  1. Would creating gui elements in code rather than creating the hierarchy ahead of time guarantee that elements are available when the code runs? Should I expect to run into problems with images loading if I change these simple objects to image labels?
  2. I don’t get any errors when the animation runs without all it’s parts. Is that an indication that the problem may be some display issue unrelated to the script?
  3. I haven’t used a bunch of :WaitForChild calls in the code (which makes me think it should error if some aren’t loading in time). Is it common practice to add those for each gui object used in a script. (hmm. I wonder if the parts not showing is due to Roundify images not loading…Should have thought of that before writing all this :smiley:)
2 Likes

If the code is in a Local Script you should be using WaitForChild for pretty much everything that requires children of an instance. Because LocalScripts run on the client, of which unlike the server, not everything will replicate in an instant, as loading times exist. It even states this on the WaitForChild documentation page.

Please read up on the post approval process. If you wanted to post in that section of the forums, you need to follow that process in order to do so.

1 Like

This is not true for all scenarios where a local script wants to access an instance. Here is the comprehensive breakdown: When to wait for replication to the client

3 Likes

There’s a process for that? Thanks, I’ll look into it. I just saw the locked icons and grayed out “New Topic” button and assumed I didn’t have enough rank to post. A link to the process in the “About _____ category” write-up would be really helpful there. I have scripting questions, but I’d also be open to opinions about whether or not playing animations before the game loads is a good idea. The “cool creations” area just seemed more appropriate for receiving a broader range of feedback (which could also include script advice).

This appears to be the process if anyone else needs it

Official Rules of the Roblox Developer Forum

15.1 You are not allowed to create topics for categories you do not have access to. Instead, please group-PM to @Post_Approval privately so the topic can be manually created.

The message title should be “Request: Posting Bug Report or Feature Request”. New Members should post their thread in Bulletin Board (#bulletin-board) and link that in the PM.

@Elttob : Thanks for that link.

This suggests that what I have should work–and it does…most of the time. That replication should extend to the images referenced in an image label/button, yes? It definitely looks like the problem is from images not showing rather than missing gui objects. So, if images linked to elements in RepFirst occasionally fail to show up, then that might just be a hiccup that I’ll have to deal with. Would creating the elements in code have any benefit there? I guess looking into ensuring images have loaded is my next thing to research.

Thanks! I appreciate all the insights.

1 Like

You could hide the loader and preload the images, then fade it in once the images are loaded!

1 Like

Yeah, I was looking at that but was concerned about having code that blocked progress inside my load screen script. Having a preloader for my loader seems like a slippery slope. Although, maybe I can use it indirectly. After looking at it again, it seems likely that part of the problem I had before was that the frames which should have held images were themselves invisible. Maybe I can move part of my RepFirst startup code to a module and put the preload stuff in there where it can set a flag when it finishes. In the video above it’s possible to see some random squares in the scene. These plain colored frames are part of a longer effect that fakes a pixellated image coming into focus. If I keep that, it buys some time for the images to load. When it’s time for the char anim to play, I can check the flag in the module and just toggle visibility on colored frames if the images haven’t loaded. I’ll try that and see how bad it looks.

Thanks again.