[Solved]Why is this module scripts parent nil when I set the parent in a function?
Asked by
6 years ago Edited 6 years ago
Ok I will let the script talk for itself:
02 | local function createButtonsAndItems(serverBaseplate, tycoonBaseplate, savedItemsTable) |
04 | for i,v in pairs (serverBaseplate:FindFirstChild( "PurchasableItems" ):GetChildren()) do |
06 | if findAMatch(savedItemsTable, v) then |
08 | local copy = serverBaseplate.PurchasableItems:FindFirstChild(v.Name):Clone() |
10 | if copy:FindFirstChild( "ItemType" ) then |
12 | if copy.ItemType.Value = = "Dropper" then |
14 | copy.Parent = tycoonBaseplate:FindFirstChild( "PurchasedItems" ) |
16 | local oreMakerCopy = game.ServerStorage.ModuleScripts:FindFirstChild( "OreMaker" ):Clone() |
18 | oreMakerCopy.Parent = copy |
inside the module script:
2 | print (script.Parent.Name) |
Output:
OreMaker:2: attempt to index field 'Parent' (a nil value)
the error is on line two of the module script