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

New Clone deletes Previous Clone?

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

✓ Accepted answer

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

2 comments

1

Yep, thanks a lot!!

0

No problem

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