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!
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 :)