ObjectValue's reference to an AnimationTrack magically disappears?

Here’s a weird one. I have this ObjectValue and I’m setting its value to an AnimationTrack. When the script that’s accessing the value initially reads it the track is there, but after waiting for a while the track vanishes and .Value is set to nil. I think it’s getting garbage collected, but that shouldn’t happen since the ObjectValue is referencing it… right?

Here’s a dance potion where you can see it in action: Dropbox - Error - Simplify your life

“Script” creates the AnimationTrack and clones TrackScript, then sets TrackScript.Track.Value to the AnimationTrack. TrackScript reads the value when it starts and prints the value, and it does the same thing after waiting a couple seconds. The value magically vanishes.

---Activated--- Tool Script: Track is AnimationTrack | Value is AnimationTrack TrackScript A: Value is AnimationTrack TrackScript B: Value is nil

To make it work I ended up using _G to contain a reference to the AnimationTrack, and that worked fine.

2 Likes

Getting similar behavior with ObjectValue references getting unset automatically o:

Would it be possible to get clarification on the garbage collection behavior we should expect for ObjectValues? :v)

Have spent a considerable amount of time figuring out what’s going on / what might work & it’d probably make more sense if someone gave a quick runthrough of what to expect

Please file a new bug report with a proper repro file that is more generically about the issue of “ObjectValue references getting unset randomly”, as OP’s repro seems to be lost now.

If you are not sure whether it is a bug please consider posting in #development-support:scripting-support first to confirm that it is not user error.