Hello, I am attempting to rewrite code I created for a stud replacer script. Originally it was located in StarterGui, however I’d like to avoid that as much as possible and instead use StarterPlayerScripts as it is only replicated once, not upon death, and it would make my life easier. One problem I’m running into however is that local scripts seem to run before any assets are loaded in even when usinggame:IsLoaded()
repeat task.wait() until game:IsLoaded()
print("Loaded.")
print(workspace.Baseplate)
This is the output code I recieve when booting up a play test. Baseplate is not a valid member of Workspace "Workspace"
When I insert a task.wait(5) to wait five seconds (waiting until the game is fully loaded manually) it works perfectly fine, with no issues whatsoever.
I have looked for other devforum posts of users with the seemingly the same issues, however they all use this method and claim it works absolutely fine. I’d like to avoid using content service if possible.
That was it! Thank you, are you able to elaborate as to why disabling streaming enabled fixes this problem, or… for that matter… what streaming enabled is in the first place? Are there any downsides to disabling it?
Edit: I viewed the creator docs on it, interesting. Thankfully my game won’t be too big, so streaming enabled wont really benefit me that much. Thanks a lot again!
And personally I think it happens because the client first loads all the things needed for game.IsLoaded to be true and then stream in all the parts inside the range (including baseplate), or game.IsLoaded doesn’t check if all the parts that need to be streamed in are streamed in, if at all.
From my personal experience streaming enabled is good for performance but very buggy in almost every other aspect of it
Alright, I’m starting to understand it better. I’m assuming to make something like this really work with streaming enabled I’d need to use content service, yeah?
Im not familiar with ContentService, and after a quick google search I only found of ContentProvider which isnt related to Steaming Enabled as far as I’m aware… Could you enlighten me?
No. ContentProviderService should not be used. That is used to load assets, such as, sounds, images, videos, decals etc. where an asset is needed to be downloaded from roblox.com to the active server, before it is used, (Often Assets in the format of: rbxassetid://[ID] (Not always, but just often)).
What you really should do is make sure that the block exists on the client, before attempting to use it.
Not always. Scripts run the second that they are loaded individually, (like if you have a local script in ReplicatedFirst, Its going to run while everything else is loading.)
The issue was the OP was using streamingEnabled which takes additional time to load BaseParts as the Client streams the parts in closest etc.
In other words, the Client was loaded, and everything was loaded, like all the scripts etc to run, but streaming enabled renders the parts after loading all other instances besides BaseParts. So in this case, workspace.Baseplate didn’t exist when game:IsLoaded() was ran