I’m trying to make it where a random model will be cloned from replicated storage and then will be parented to workspace. After that happens I want that cloned model too then move and get destroyed. In my case I want a car (model) to be cloned and then parented into workspace which will then move in a straight line for a little while and then be destroyed.
Here is what I have so far -
local CarFolder = game.ReplicatedStorage.Cars
local Dest = CFrame.new(73.783, 49.815, 186.905)
local function Move()
local items = CarFolder:GetChildren()
local randomItem = items[math.random(1, #items)]
local item = randomItem:Clone()
item.Parent = game.Workspace
item:SetPrimaryPartCFrame(Dest)
wait(3)
for i = 0,1,.001 do
item:SetPrimaryPartCFrame(item:GetPrimaryPartCFrame() * CFrame.new(0,0,1))
end
item:Destroy()
end
while true do
Move()
end
It should be working but the problem I’m having is that when the model is cloned, that cloned model doesn’t have a primary part anymore. I am not sure how to fix that and would appreciate some help. Thanks.
After you clone the car and parent it to workspace you need to : item:MakeJoints()
local CarFolder = game.ReplicatedStorage.Cars
local Dest = CFrame.new(73.783, 49.815, 186.905)
local function Move()
local items = CarFolder:GetChildren()
local randomItem = items[math.random(1, #items)]
local item = randomItem:Clone()
item.Parent = game.Workspace
item:MakeJoints()
item:SetPrimaryPartCFrame(Dest)
wait(3)
for i = 0,1,.001 do
item:SetPrimaryPartCFrame(item:GetPrimaryPartCFrame() * CFrame.new(0,0,1))
end
item:Destroy()
end
while true do
Move()
end
“Model:GetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.”
“Model:GetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.
Seems like your model doesn’t have a PrimaryPart set on. You need to set the primarypart if you want it to work.
Also, you should use PivotTo [ better].