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:
01 | local ServerStorage = game.ServerStorage |
02 |
03 | function Regen() |
04 | local X = math.random( 0 , 1 ) |
05 | if X = = 1 then |
06 | ServerStorage.Model 1 :Clone() |
07 | ServerStorage.Model 1. Parent = workspace |
08 | wait( 2 ) |
09 | workspace.Model 1 :Destroy() |
10 | print ( "X was 1" ) |
11 | end |
12 | if X = = 0 then |
13 | ServerStorage.Model 0 :Clone() |
14 | ServerStorage.Model 0. Parent = workspace |
15 | wait( 2 ) |
Cheers!
You shouldn't be destroying the model after you clone it.
01 | local ServerStorage = game.ServerStorage |
02 |
03 | function Regen() |
04 | local X = math.random( 0 , 1 ) |
05 | if X = = 1 then |
06 | Model 1 Clone = ServerStorage.Model 1 :Clone() |
07 | Model 1 Clone.Parent = workspace |
08 | wait() |
09 | print ( "X was 1" ) |
10 | end |
11 | elseif X = = 0 then |
12 | Model 0 Clone = ServerStorage.Model 0 :Clone() |
13 | Model 0 Clone.Parent = workspace |
14 | wait() |
15 | print ( "X was 0" ) |
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:
01 | local ServerStorage = game.ServerStorage |
02 |
03 | function Regen() |
04 | local X = math.random( 0 , 1 ) |
05 | if X = = 1 then |
06 | Model 1 Clone = ServerStorage.Model 1 :Clone() |
07 | Model 1 Clone.Parent = workspace |
08 | wait() |
09 | ServerStorage.Model 1 :Destroy() |
10 | print ( "X was 1" ) |
11 | end |
12 | elseif X = = 0 then |
13 | Model 0 Clone = ServerStorage.Model 0 :Clone() |
14 | Model 0 Clone.Parent = workspace |
15 | wait() |
Please press the answer button (wherever it is I forgot) if this helped. I'd gladly appreciate it :)