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

New Clone deletes Previous Clone?

Asked by 4 years ago

Hey guys, so I'm working on an enemy spawn script and I'm not sure this is the best idea, but I run into this all the time with cloning.

So basically every time I clone something, for example if I have a button cloning something (for instance a tool) from server storage then when i click it a second time it just deletes the old one. Can anyone help me with this?

local clone = game.ReplicatedStorage.XenScripted:Clone()

while true do
        clone.Parent = game.Workspace
        clone:MoveTo(Vector3.new(47.71, 11.422, -150.51))
    wait(math.random(3,10))
end

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

I see the issue. You cloned it out of the while true do loop so it deletes itself and teleport's itself back to the position that it was when it was cloned.

while true do
    local clone = game.ReplicatedStorage.XenScripted:Clone()
        clone.Parent = game.Workspace
        clone:MoveTo(Vector3.new(47.71, 11.422, -150.51))
        wait(math.random(3,10))
end
1
Yep, thanks a lot!! xIshFudge 84 — 4y
0
No problem Lakodex 711 — 4y
Ad

Answer this question