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 4 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.

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

Log in to vote
0
Answered by 4 years ago

package and cloned should change places i guess

Ad
Log in to vote
0
Answered by 4 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:

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!

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

Answer this question