When the player selects an object, parts are created to show the player that that object has been highlighted. The problem is, I want to unhighlight the previously selected parts when the player selects a new object(s).
I thought of adding the selected objects to a table, then destroying the highlights attached to those parts in the table whenever the method is called. However, I would have to define this table whenever a part is selected, thus wiping the table whenever a new part is selected. Meaning I cant destroy the highlights attached to the previously selected parts.
function Module.new(Obj)
local self = setmetatable({}, Module)
self.Obj = Obj -- Obj is a table of selected parts
self.PrevObj = {}
return self
end
function Module:Highlight()
for _, part in pairs(self.Obj) do
table.insert(self.PrevObj, part) -- Insert selected parts into PrevObj table
-- Create and weld highlights to parts
end
end)