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.

4 comments

0

Your code works for me when I tested it. Is there an error in the output?

0

It outputs this : 10:38:33.378 - SetPrimaryPartCFrame is not a valid member of Part

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

0

Oh my god thanks so much!!! wish i could upvote!