The Parent property of (cloned part) is locked, current parent: NULL, new parent Workspace

So, I know the title may be confusing, but I’ve been working on an airdrop system for 2 days now and I keep getting the same error image

I have a script in ServerScriptService titled AirDropHandler, inside that script is the following:

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

if not ChatService:GetChannel("All") then
	while true do
		local ChannelName = ChatService.ChannelAdded:Wait()
		if ChannelName == "All" then
			break
		end
	end
end

--Make your speaker and have it join the 'All' channel we waited for
local Notify = ChatService:AddSpeaker("Notify")
Notify:JoinChannel("All")

--Change data for your speaker such as name color, chat color, font, text size, and tags
Notify:SetExtraData("NameColor", Color3.fromRGB(255, 0, 191))
Notify:SetExtraData("ChatColor", Color3.fromRGB(255, 255, 204))




local airdrop = game.ReplicatedStorage:WaitForChild("Airdrop")
local clone = airdrop:Clone()
while wait(math.random(30,50)) do
	
	print("an airdrop is falling")
	Notify:SayMessage("An Airdrop is falling.","All")
	clone.Parent = game.Workspace
	clone.Position = Vector3.new(math.random(-400,400),300,math.random(-400,400))
	clone.BodyForce.Force = Vector3.new(0,2900,0)
end

And then in ReplicatedStorage, I keep the part named “Airdrop”. Inside Airdrop there are two scripts:
script number 1:

local Debris = game:GetService("Debris")
local function crate(plr)
	
	
	local guns = {"M17","Katana","PARA-FAL","M2 Browning","Crucible","AK47","AK12","HHG","Intervention","L119A2","R700","SVDS","STG44","HK G3","FN FAL","Barrett M107"}
	local randomselect = math.random(1,#guns)
	local selected = guns[randomselect]
	
	game.ReplicatedStorage.Guns[selected]:Clone().Parent = plr.Backpack

	Debris:AddItem(script.Parent,0.1)
	
	script.Parent:Clone().Parent = game:GetService("ReplicatedStorage")
	
end
script.Parent.ProximityPrompt.Triggered:Connect(crate)

And the second script is:

local Debris = game:GetService("Debris")
local function Touched()

	script.Parent.BodyForce.Force = Vector3.new(0,0,0)
	script.Parent.ProximityPrompt.Enabled = true

end
script.Parent.Touched:Connect(Touched)

There is also a ProximityPrompt inside the airdrop and a BodyForce to make the airdrop fall slower.

When the wait() timer runs down, the airdrop clones and falls to the ground. The second time, the error occurs.

You only made one clone; within those 30-50 seconds that clone could’ve been destroyed or anything really.

Try putting local clone = airdrop:Clone() inside the while loop instead

1 Like

As @kojocrash said you are only cloning the airdrop the first time the code runs, not in every loop circle. Then the only airdrop that actually gets cloned gets cleaned using Debris:AddItem(script.Parent, 0.1)(assumption) which destroys the object(destroying an object also locks the object parent to NULL) and afterwards the script tries to change the parent again causing the error to occur. Instead you should create a new clone every time the loop runs:

while wait(math.random(30,50)) do
	local clone = airdrop:Clone() --airdrop gets cloned inside the loop instead
	print("an airdrop is falling")
	Notify:SayMessage("An Airdrop is falling.","All")
	clone.Parent = game.Workspace
	clone.Position = Vector3.new(math.random(-400,400),300,math.random(-400,400))
	clone.BodyForce.Force = Vector3.new(0,2900,0)
end