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 4 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:

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!

0
On line 22 it should just be "Regen()" not "Regen(Regen)" since your function doesn't take any arguments. docrobloxman52 407 — 4y
0
thank you. MradmannMvip 50 — 4y
0
Why are you destorying the clone after you clone it? SilverCreeper58 23 — 4y
0
wait. MradmannMvip 50 — 4y
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 — 4y
0
I don't understand. What do you mean. SilverCreeper58 23 — 4y
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 — 4y

1 answer

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

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

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 — 4y
0
OOOOOOOOH MradmannMvip 50 — 4y
Ad

Answer this question