#I need help in making a OOP function to destroy trash in my game without leaving any instances of it
1 messages · Page 1 of 1 (latest)
try weak tables
if the referenced part is removed, it will also be removed from table
you should be able to just do TrashClass.__mode = "v"
iirc
I mean it will do exacly what you want no?
When you destroy tool you try to remove all references from table
Weak tables auto do that
If referenced part gets niled, reference is gone
Litterally this
It's just metatable
Which you're already using
Just add .__mode
Possible values are v k kv
V-value
K-key
Ye
Just double check it it causes mem leak or nah cuz I might be wrong but don't think so
Huh
Wdym
The class itself will be a weak table
Show
Maybe I fucked up something
Ye bc u try to clean up when it's already gone due to weak table
I think
What's the for loop for then
That has comment to litteraly remove reference
gc will collect it
as a developer who has been learning lua almost every day for over a year now I have never even heard of this
Ik OOP, but like damn what is this
learn more
Well thats already what I’m doing on a daily basis
** You are now Level 32! **
F U C K O F F