I have a system that spawns clouds with a folder inside it. When the clouds are destroyed, the folders in the cloud gets transferred to the workspace.
The code works as intended, although, I got an error that says the folder’s parent property is locked.
This occurred right when I stopped the game so I’m not sure what it did.
My goal is to figure out why the error appeared, how did it affect the game, and how could I prevent it.
Function from the error (Picture of Error Code Below):
local function handlePatataSpawning(cloud, cloudType)
local amountOfPatatas = 0
local patata = getPatataByCloudType(cloudType)
local patataFolder = cloud:FindFirstChild("PatataFolder")
task.spawn(function()
moveCloud(cloud)
end)
repeat
wait(.25)
if math.random(1, 2) == 1 then
amountOfPatatas += 1
createNewPatata(patata, cloud)
end
until amountOfPatatas >= maxPatatas
patataFolder.Parent = workspace -------- The problem that occured
cloud:Destroy()
cloudsInPlay -= 1
end
