Hello, I want to clone my item table into the workspace but I always get this: attempt to call method 'Clone' (a nil value), but It should have a value
Script:
local serverstorage = game:GetService("ServerStorage") local items = {serverstorage.Folder.food, serverstorage.Folder.food1, serverstorage.Folder.food2} for i, v in pairs(items) do local item = (items):Clone() item.Parent = workspace end
Thank you.
It would be easier to start with an empty table and insert the names of the items first and then clone them and put them into workspace.
ServerScript inside of ServerScriptService
--// Empty Table local items = {} --// Where You Want Them To Load Into [CHANGEABLE] local loadPlace = game:GetService("Workspace") --// Folder You Want To Load Into The Table [CHANGEABLE] local folder = game:GetService("ServerStorage"):WaitForChild("Folder") --// Change Folder To The Name Of YOUR Folder --// Waits For Game To Set [CHANGEABLE] wait(2.5) --// Inserts All Items From ServerStorage Folder Into Table for _,item in pairs(folder:GetChildren()) do table.insert(items,item.Name) wait() end --// Waits For The Table To Settle In [CHANGEABLE] wait(1) --// Finds All The Items In The Folder With The Name Of The Current Item, Clones It, And Puts It Into The LoadPlace Variable for _,item in pairs(items) do local newItem = folder:FindFirstChild(item):Clone() newItem.Parent = game:GetService(loadPlace) print("Loaded "..item.." Into "..loadPlace) --// This Line Is For Testing Purposes [CHANGEABLE] wait() end
1) Created an empty table to store all the values
2) Set all easy changeable variables
3) Inserted all the names of the items inside the folders in ServerStorage into the table
4) Looked for the name of the item in the folder in ServerStorage and cloned it into workspace
Hope this helped! If it didn't work, let me know by commenting down below what error occurs. If it does work, let me know by taking this as the answer!
~killerbrenden
items
is the table, what you actually want is to clone v
as that is the Instance
Wiki
Don't forget to mark my answer as the solution if it solved your problem :)