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

Part gets deleted after another part has been cloned?

So im trying to make an airdrop script and when i run the script, the object clones and falls to the ground, i set it to repeat so it continually does this but when another object clones, the first one disappears.

Here is my code.

local waittime = (4)
local destroytime = (10)

local package = game.ServerStorage.Drop

local cloned = package:Clone()

local DropLocation = game.Workspace.DropZone

local Drop = true
while true do
wait(waittime)

package:Clone()
print("Cloned")

cloned.Parent = game.Workspace
cloned.Center.CFrame = game.Workspace.DropZone.CFrame
print("Summoned Into Workspace")
end

2 answers

The reason your script is not working is because you only clone the object once, and you repeatedly set the position of the object to the DropZone. The way to fix this is to define your cloned variable inside of the loop:

while true do
	wait(waittime)
	 
	local cloned = package:Clone()
	print("Cloned")
	 
	cloned.Parent = game.Workspace
	cloned.Center.CFrame = game.Workspace.DropZone.CFrame
	print("Summoned Into Workspace")
end

What you were doing is cloning the package but not assigning that clone to anything. You were using the initial clone. This new way, however, assigns the cloned object to a new variable each iteration, and we put that into the workspace.

I hope this helps!

2 comments

0

Thank you so much! it works now!

0

Check out my YouTube channel for more Roblox Scripting Content and Help! https://www.youtube.com/channel/UCxH4DBOEzsrpvEL1yE30lcw/

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