Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

`The Parent property of cloneBox is locked, current parent: NULL, new parent Workspace` Error?

My Script runs only twice, then it stops working

Basically, a script moves to a roller, when player clicks it, and they deliver it to a zone, the tool gets detroyed, it works but only for 2 times. Error: The Parent property of cloneBox is locked, current parent: NULL, new parent Workspace

So it works when the game starts, then again, but no more after. Help!

Both are Scripts

Script one: To make the script run for the first time

local theBox = game.ServerStorage.BoxItem
local cloneBox = theBox:Clone()
local boxWeapon = game.ServerStorage.boxWeapon
local clonedboxWeapon = boxWeapon:Clone()
	wait(5)
cloneBox.Parent = game.Workspace
cloneBox.Name = "cloneBox"
local ts = game:GetService("TweenService")
local objPropertiesToModify = cloneBox
local goal = {}
goal.CFrame = CFrame.new(823.84, 235.498, -265.94)
local tween = ts:Create(objPropertiesToModify, TweenInfo.new(2), goal) tween:Play()
ts:Create(objPropertiesToModify, TweenInfo.new(2), goal)
cloneBox.ClickDetector.MouseClick:Connect(function(click)
	print("Hellol")
		if game.Workspace:FindFirstChild("cloneBox") then
			game.Workspace.cloneBox:Destroy()
			clonedboxWeapon.Parent = click.Backpack
			end
		end)

Second Script: To make script run forever if the statement works

local theBox = game.ServerStorage.BoxItem
local cloneBox = theBox:Clone()
local boxWeapon = game.ServerStorage.boxWeapon
local clonedboxWeapon = boxWeapon:Clone()
function reSpawntheBox()
	wait(1)
cloneBox.Parent = game.Workspace
cloneBox.Name = "cloneBox"
local ts = game:GetService("TweenService")
local objPropertiesToModify = cloneBox
local goal = {}
goal.CFrame = CFrame.new(823.84, 235.498, -265.94)
local tween = ts:Create(objPropertiesToModify, TweenInfo.new(2), goal) tween:Play()
ts:Create(objPropertiesToModify, TweenInfo.new(2), goal)
cloneBox.ClickDetector.MouseClick:Connect(function(click)
	print("Hellol")
		if game.Workspace:FindFirstChild("cloneBox") then
			game.Workspace.cloneBox:Destroy()
			clonedboxWeapon.Parent = click.Backpack
			end
		end)
	end
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if hit.Parent:FindFirstChild("boxWeapon") then
			-- PLAYER TOUCH THE BOX
			print("Bringed the Box")
			hit.Parent:FindFirstChild("boxWeapon"):Destroy()
		reSpawntheBox()
		end
	end
end)

3 comments

0

I don't have a credible source to back my understanding of this error, though, through multiple experiences and a faded memory of a solution, I believe this is caused from repetitive destruction of Objects as a measure against malicious intentions? 

0

Try setting the parent's to nil intsead.

0

I tried to set the Parent to nil, i still get the same error :/

1 answer

Basically, The Error was When you clone something, and use a function, Clone it inside the function, otherwise it Gets Locked!

This discussion is preserved as it was. New answers, comments, and votes are closed.