Adding Instances to Troves?

  1. What do you want to achieve? Keep it simple and clear!
    Add Instances created into a Trove to clean up later.

  2. What is the issue? Include screenshots / videos if possible!
    I do not understand Troves enough, but am making progress. Whenever I try
    myTrove:Add(myVectorForce), I get this error saying invalid argument to #1, to 'insert', as if it expects a table.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I went through the docs again and again wondering what I missed. Tried alternatives like myTrove:Clone(), myTrove:Construct(), but even those resulted in the same error. There’s no posts focused on Troves, so I’m having a hard time learning it.

--// somewhere in the start
local myTrove = Trove.new()
--// main code chunk
local moveForce = Instance.new("VectorForce")
	moveForce.Name = "thrust"
	moveForce.Attachment0 = hrp:WaitForChild("rootAtt")
	moveForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	moveForce.Parent = hrp

myTrove:Add(moveForce) --// Errors here
--// somewhere in the end
myTrove:Clean()

This works perfectly for me:

local Trove = require(game.ServerStorage.Trove)
local t = Trove.new()
local vf = Instance.new("VectorForce")
vf.Parent = game.Workspace
t:Add(vf)
t:Clean()
print("Cleaned")

You should look at the place in the code (yours or Trove) where it errors. Can you post line no.? And please make sure you have the latest version, I’m assuming that’s the one here https://github.com/Sleitnick/RbxUtil/blob/main/modules/trove/init.lua

3 Likes