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

The Model wont clone itself? Help?

Asked by 5 years ago

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:

01local ServerStorage = game.ServerStorage
02 
03function Regen()
04    local X = math.random(0,1)
05    if X == 1 then
06        ServerStorage.Model1:Clone()
07        ServerStorage.Model1.Parent = workspace
08        wait(2)
09        workspace.Model1:Destroy()
10        print("X was 1")
11    end
12    if X == 0 then
13        ServerStorage.Model0:Clone()
14        ServerStorage.Model0.Parent = workspace
15        wait(2)
View all 24 lines...

Cheers!

0
On line 22 it should just be "Regen()" not "Regen(Regen)" since your function doesn't take any arguments. docrobloxman52 407 — 5y
0
thank you. MradmannMvip 50 — 5y
0
Why are you destorying the clone after you clone it? SilverCreeper58 23 — 5y
0
wait. MradmannMvip 50 — 5y
View all comments (3 more)
0
i want to delete the clone, that the Parent is workspace, which is supposed to be deleted, and replaced with another clone later. MradmannMvip 50 — 5y
0
I don't understand. What do you mean. SilverCreeper58 23 — 5y
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. MradmannMvip 50 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

01local ServerStorage = game.ServerStorage
02 
03function Regen()
04    local X = math.random(0,1)
05    if X == 1 then
06        Model1Clone = ServerStorage.Model1:Clone()
07        Model1Clone.Parent = workspace
08            wait()
09        print("X was 1")
10    end
11    elseif X == 0 then
12        Model0Clone = ServerStorage.Model0:Clone()
13        Model0Clone.Parent = workspace
14        wait()
15        print("X was 0")
View all 22 lines...

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:

01local ServerStorage = game.ServerStorage
02 
03function Regen()
04    local X = math.random(0,1)
05    if X == 1 then
06        Model1Clone = ServerStorage.Model1:Clone()
07        Model1Clone.Parent = workspace
08            wait()
09        ServerStorage.Model1:Destroy()
10        print("X was 1")
11    end
12    elseif X == 0 then
13        Model0Clone = ServerStorage.Model0:Clone()
14        Model0Clone.Parent = workspace
15        wait()
View all 24 lines...

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

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! :) MradmannMvip 50 — 5y
0
OOOOOOOOH MradmannMvip 50 — 5y
Ad

Answer this question