Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part gets deleted after another part has been cloned?

Asked by 5 years ago

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.

01local waittime = (4)
02local destroytime = (10)
03 
04local package = game.ServerStorage.Drop
05 
06local cloned = package:Clone()
07 
08local DropLocation = game.Workspace.DropZone
09 
10local Drop = true
11while true do
12wait(waittime)
13 
14package:Clone()
15print("Cloned")
16 
17cloned.Parent = game.Workspace
18cloned.Center.CFrame = game.Workspace.DropZone.CFrame
19print("Summoned Into Workspace")
20end

2 answers

Log in to vote
0
Answered by 5 years ago

package and cloned should change places i guess

Ad
Log in to vote
0
Answered by 5 years ago

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:

01while true do
02    wait(waittime)
03 
04    local cloned = package:Clone()
05    print("Cloned")
06 
07    cloned.Parent = game.Workspace
08    cloned.Center.CFrame = game.Workspace.DropZone.CFrame
09    print("Summoned Into Workspace")
10end

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!

0
Thank you so much! it works now! Oscargamingvr 9 — 5y
0
Check out my YouTube channel for more Roblox Scripting Content and Help! https://www.youtube.com/channel/UCxH4DBOEzsrpvEL1yE30lcw/ Sir_Ragealot 72 — 5y

Answer this question