ObjectValues Cleared when Testing, But Only When They Reference Parts?

I have a LocalScript in StarterPlayerScripts that has a bunch of ObjectValues that reference various parts of the game, and the script uses those ObjectValues to detect when those parts are touched to fire different events (it’s a single player game so everything is local).

In the first chapter, it has worked and still works perfectly fine; however, in the next chapter that I’m making - which is a separate place file - those ObjectValues in the script keep getting set to nil when I actually test the game.

What’s even weirder, is that only some of them do; the ObjectValues whose values are set to Models remain just fine, and it’s only the those whose values are Parts that are cleared.


I have made extra-extra sure that there is not a single script in the Place that changes the parts I’m referencing (like cloning them and changing their parent or something).

I also noticed that when I have the same set of ObjectValues in the workspace instead, they remain just fine. I thought that maybe it was because the client can’t replicate ObjectValues or something but I know it can because it did in the first chapter.

I have zero idea why the values are being cleared or what to do about it. It’s incredibly annoying because it’s completely halting my development on the place for now.

Am I correct in assuming you turned on StreamingEnabled, or otherwise have it set to enabled?
I believe the parts are just not loaded in, causing the object value to show it as nil.

This matches with the models showing up, as they are always loaded for the client (just not the children of the models)

Oh yes, of course!

But if there’s a lot of content in the workspace, wouldn’t keeping SteamingEnabled on hinder the game’s performance a bit?

It’d be better for performance to keep StreamingEnabled on.
It will require some work arounds to allow you to access the objects in the ObjectValues. I’m not sure whether ObjectValues would even really work with StreamingEnabled

(slight disclaimer - I don’t deal with maps large enough to worry about streaming enabled)

1 Like

I’m not sure how big the map has to be to make it a performance issue. Mine is just random clusters of halves of rooms since it’s mostly a 2D/top down game, so I’d assume (hope) that it doesn’t become too much of an issue. Plus the design style is rather simple, so there’s not very many parts to begin with.

Thanks, this really helped

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