Hi, im trying to clone a model and move it to a specific position.
if raycastResult then
local part = game.Workspace.Ores.Ore:Clone() --This is a model, i set the primary part manually.
part.Parent = game.Workspace.SpawnedOres
local newCFrame = CFrame.new(raycastResult.Position)
part:SetPrimaryPartCFrame(newCFrame)
print("spawned")
end
If i use part:SetPrimaryPartCFrame(newCFrame) it gives me an error saying that the model DOESN’T have a Primary Part.
If i delete SetPrimaryPart… then it just copies an empty model.
I think you have to call MakeJoints() in order to properly create the Model properly in relevance to its PrimaryPart, perhaps try this?
if raycastResult then
local part = game.Workspace.Ores.Ore:Clone() --This is a model, i set the primary part manually.
part.Parent = game.Workspace.SpawnedOres
part:MakeJoints()
local newCFrame = CFrame.new(raycastResult.Position)
part:SetPrimaryPartCFrame(newCFrame)
print("spawned")
end
All you have to do is define the PrimaryPart property it should look something like this:
if raycastResult then
local part = game.Workspace.Ores.Ore:Clone() --This is a model, i set the primary part manually.
part.PrimaryPart = part.Ore
part.Parent = game.Workspace.SpawnedOres
local newCFrame = CFrame.new(raycastResult.Position)
part:SetPrimaryPartCFrame(newCFrame)
print("spawned")
end