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

I need help with a script cloning a part multiple times at random locations?

Asked by 4 years ago
Edited 4 years ago

I need help with a script cloning a part mutliple times at random locations Hello I am new at coding and after some research i came up with this..

while true do       
    local part = game.ServerStorage.bush
    local clonedbush = part:Clone() 
    local x = math.random(-1020,1024)
    local y = 1
    local z = math.random(-1020,1024)--where the models will spawn


    clonedbush.Parent = game.Workspace --puts clone in game
    clonedbush:SetPrimaryPartCFrame(CFrame.new(x, y, z))
    wait(3)--how long to spawn more
end 

yes the model is called bush... This code wont spawn more than 1 model and it will spawn it at the same location and not at a random one, please help me fix this.

0
Your code works for me when I tested it. Is there an error in the output? Sparks 534 — 4y
0
It outputs this : 10:38:33.378 - SetPrimaryPartCFrame is not a valid member of Part Mast3rStRix 43 — 4y
1
:SetPrimaryPartCFrame is a member function of the Model instance. If you are using a part then you will have to replace line 10 in the snippet with clonedbush.CFrame = CFrame.new(x,y,z). Sparks 534 — 4y
0
Oh my god thanks so much!!! wish i could upvote! Mast3rStRix 43 — 4y

Answer this question