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

I've tried different versions of Clone() but I can't seem to make anything clone more than once?

Asked by 4 years ago

I was trying to build a building that is sort of like a spiral staircase that will copy or clone the first level, then rotates it as it gets higher, and then stacks the next level on top of the earlier level, and then repeats that many times, but I couldn't find anything on how to do it by code.

For example, I have built the first level and want to find a way to clone it more than one time while also and rotating it. This is instead of manually copying, rotating and pasting it 100 times.

My first and biggest obstacle so far is that I can't seem to make something clone more than once.

I've read a number of help articles and watched videos on YouTube but I am new to this kind of scripting and I think I am missing something obvious.

Right now, here is what I have in the code -- I figure I need to get this first step working before I can move on to the other things I want to do:

while true do
    local fullbase = game.ServerStorage.fullbase:Clone()
        fullbase.Parent = game.Workspace
    fullbase.Position = Vector3.new(0, 9, 0)

    wait(.1)
end

"fullbase" is the object that is made up of several pieces put together.

I got the idea to put the part in ServerStorage from another posting, and anyway when I run this code, the fullbase object appears, but only once. From what I see, maybe only one of the lines is making it go to the workspace which is why I think it is showing up just once.

I have already tried a number of other code snippets from many other posts on cloning (below) but none of them work! I think maybe the other help posts leave out some sort of detail that I am missing?

Here are the other versions I've tried (commented out):

``-- First thing I tried:
--local object = game.Workspace.E
--local clonedObject = object:Clone()
--clonedObject.Parent = game.Workspace
--clonedObject.Position = Vector3.new(77.994,18,73.661)

-- Second thing I tried:
--local part = script.Parent
--for count = 1, 10 do -- clones 10 times
    --local clone = part:Clone()
    --local m = math.random(3,8)
    --clone.Position = clone.Position + Vector3.new(m, 0,m) 
    --clone.Parent = workspace
--end

-- Third thing I tried:
---- Get a reference to an existing object
--local original = workspace.fullbase
---- Create the model copy
--local copy = original:Clone()
---- Parent the copy to the same parent as the original
--for i = 1, 10
--copy.Parent = original.Parent
---- Move the copy so it's not overlapping the original
    --copy:SetPrimaryPartCFrame(CFrame.new(0, 50*i, 0))

    --for i = 1,10 do
         --local brick = game.Workspace.fullbase:Clone()
                --brick.Parent = game.Workspace
               -- brick.Position = Vector3.new(0,50,0) -- Put the position.
               -- -- for set model position you can use brick:SetPrimaryPartCFrame(CFrame.new(0,0,0))
               -- wait(0.7)
--end


I just need to figure out this first step and then I hope I can do the rest of it by myself. Thank you so much!

0
wait so the spiral staircase does it go 360 or less? Pitched_mobile 191 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
YourPart = game.ServerStorage.Yourpart --sepecify ur part here

local height = 20 --this is ur builds height
local time = 5 --i wouldnt set it alot smaller because its gonne be laggy

--the rest will work without touching it
while true do

    local YourClone = YourPart:Clone()

    YourClone.Parent = game.Workspace --i do recommend using a folder instead of ur workspace game.Workspace.Folder

    YourClone.Position = YourClone.Position + Vector3.new(0,height,0)

    YourPart.Position = YourClone.Position

    --YourClone.Orientation = YourClone.Orientation + Vector3.new(0,-90,0) <- you can add this if you want it to turn

    wait(time)

end
0
if u got questions u can dm Pitched_mobile 191 — 4y
0
Thanks so much for trying to help! But I think I am still doing something wrong because when I used the code it didn't work. alejandrobes2 0 — 4y
0
well first ur stairvase cannot be a model Pitched_mobile 191 — 4y
0
second it has to be located in ServerStorage Pitched_mobile 191 — 4y
0
third the script must be a serverscript because local scripts cannot see serverstorage. To the local script, serverstorage seems empty. Thats why exploits like dex explorer can't detect stuff in ServerStorage. Making it more secure than ReplicatedStorage NGC4637 602 — 3y
Ad
Log in to vote
0
Answered by 4 years ago

Thank you so much for trying to help! But I must be doing something wrong because it still doesn't work :( (I tried to paste my code in the comment above but it wouldn't let me format it, so I'm trying it here):

fullbase = game.ServerStorage.fullbase
local height = 11.617
local time = 5
while true do
    local YourClone = fullbase:Clone()
    YourClone.Parent = game.Workspace.clonefolder
    YourClone.Position = YourClone.Position + Vector3.new(0, height, 0)
    YourClone.Orientation = YourClone.Orientation + Vector3.new(1,0,0)
    wait(1)
end
0
else u can add me to ur game in studio with teamcreate Pitched_mobile 191 — 4y

Answer this question