Input1080
(Input)
November 6, 2022, 3:25am
#1
I am trying to call a inserted item inside a table to be called back out and parented back into the Workspace of the game. But I keep getting errors.
Picture of Item Setup:
Line in my script that inserts items into table:
local StoredPurchase = {}
for _,Item in pairs(Purchase:GetChildren()) do
table.insert(StoredPurchase, Item)
Item:Destroy()
end
Line in my script that im trying to reinsert into Workspace:
for _,Item in pairs(StoredPurchase) do
if Item.Name == ButtonName then
Item.Parent = Purchase
end
end
Kaid3n22
(Kaiden)
November 6, 2022, 3:29am
#2
Input1080:
Item:Destroy()
You destroy the item, causing it to not be able to be reparented.
Input1080
(Input)
November 6, 2022, 3:30am
#3
But. Why would that matter? Because it stored a copy of the item into the table.
Kaid3n22
(Kaiden)
November 6, 2022, 3:31am
#4
If you wanted it like that, you would probably have to use a clone of the item. Inserting the item into a table doesn’t create a whole new item, rather puts a reference of the item into a table, making destroying it equivalent to destroying the item inside of the table.
1 Like
jufdnhf
(jufdnhf)
November 6, 2022, 3:32am
#5
It didn’t store a copy in the table, it stored a reference to the object. Whatever you do to the object, it will be referenced in the table.
system
(system)
Closed
November 20, 2022, 3:32am
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.