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

The Model wont clone itself? Help?

So, i've been testing this regen script, that selects a random model between the 2 that exist for now(Model1 and Model0). The script begins by checking if X equals to 0 or 1, to select which map will be choosen in the next round. Then the choosen model will clone itself, and here is where the trouble is.

No errors, the Model is archivable, and it wont clone. What did i do wrong?

Script:

local ServerStorage = game.ServerStorage

function Regen()
	local X = math.random(0,1)
	if X == 1 then
		ServerStorage.Model1:Clone()
		ServerStorage.Model1.Parent = workspace
		wait(2)
		workspace.Model1:Destroy()
		print("X was 1")
	end
	if X == 0 then
		ServerStorage.Model0:Clone()
		ServerStorage.Model0.Parent = workspace
		wait(2)
		workspace.Model0:Destroy()
		print("X was 0")
	end
end

while true do
	Regen(Regen())
	wait(2)
end

Cheers!

7 comments

0

On line 22 it should just be "Regen()" not "Regen(Regen)" since your function doesn't take any arguments.

0

thank you.

0

Why are you destorying the clone after you clone it?

0

wait.

0

i want to delete the clone, that the Parent is workspace, which is supposed to be deleted, and replaced with another clone later.

0

I don't understand. What do you mean.

0

i the model to be cloned, then it will be moved to workspace, so it can be the next map, then, after some time, it would be deleted, so that another map can take place.

1 answer

✓ Accepted answer

You shouldn't be destroying the model after you clone it.

local ServerStorage = game.ServerStorage

function Regen()
	local X = math.random(0,1)
	if X == 1 then
		Model1Clone = ServerStorage.Model1:Clone()
		Model1Clone.Parent = workspace
        	wait()
		print("X was 1")
	end
	elseif X == 0 then
		Model0Clone = ServerStorage.Model0:Clone()
		Model0Clone.Parent = workspace
		wait()
		print("X was 0")
	end
end

while true do
	Regen()
	wait(2)
end

And PLEASE, don't use spaces as indents. Use "Tab" instead. It's much better.

If you want to destroy the one in serverstorage, do:

local ServerStorage = game.ServerStorage

function Regen()
	local X = math.random(0,1)
	if X == 1 then
		Model1Clone = ServerStorage.Model1:Clone()
		Model1Clone.Parent = workspace
        	wait()
		ServerStorage.Model1:Destroy()
		print("X was 1")
	end
	elseif X == 0 then
		Model0Clone = ServerStorage.Model0:Clone()
		Model0Clone.Parent = workspace
		wait()
		ServerStorage.Model0:Destroy()
print("X was 0")
	end
end

while true do
	Regen()
	wait(2)
end

Please press the answer button (wherever it is I forgot) if this helped. I'd gladly appreciate it :)

2 comments

0

thats not what i mean't though, thank you for trying to help! i appreciate that people like are helping new scripters in this site! :)

0

OOOOOOOOH

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