Infinite yield and streaming

yo! i need some help with a problem that has to do with “WaitForChild”. i have few scripts that change lighting whenever a player enters the area, but i have streaming enabled on my game which makes the scripts yield forever and when those lighting area parts are loaded in, it doesn’t work. How would i fix this??
i cannot afford to disable streaming or remove the scripts. they are extremely important!!

ah! to add, the script resides in starterplayerscripts!

First, I would familiarize yourself with how content streaming works by reading this article.

But you have two options. Option one is create these light instances on the client to make them not part of content streaming because the server doesn’t have a copy of the instances. Simple but sorta defeats the purpose of content streaming if you do it to a lot of instances.

Option two is to utilize CollectionService and it’s correspodning events GetInstanceAddedSignal() and GetInstanceRemovedSignal() to apply changes to lights as they are added/removed from the client’s workspace. Basically make a function that runs when a light object is loaded in.

so sorry if i am reading/understanding this wrong but with lighting i don’t mean a light part, but the ingame lighting settings (if u get what i mean by that). which gets activated when a player gets inside a part thats in the map. would these still work in this case?

Yes, either could still work for this.

sorry this may be a weird question but, is the reason why the script breaks because its activated by touch…? i noticed that i had an older project with streaming on and similar local lighting change script but instead it is activated by clickdetector and it worked. is it normal for content streaming to behave like this?

nvm. forget what i said ;_;! i did some digging and just decided to use a remote event system to handle my lighting stuff, it works, atleast for now…??? so i guess its solved for now, if this is poor way to handle things LMK. + thanjs for your help xZylter!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.