Problem: Model wont clone into game.Workspace.Blocks
I have a part saving system, here is the save script:
local DSS = game:GetService("DataStoreService")
local modelDataStore = DSS:GetDataStore("Models")
game.Players.PlayerAdded:Connect(function(player)
local models = {}
for _, model in pairs(game.Workspace.Blocks:GetChildren()) do
local modelData = {}
local primaryPart = model.PrimaryPart
local position = primaryPart.Position
local direction = primaryPart.CFrame.lookVector
modelData.ModelName = model.Name
modelData.Position = {position.X, position.Y, position.Z, direction.X, direction.Y, direction.Z}
models[#models + 1] = modelData
print(models.ModelName)
end
modelDataStore:SetAsync(player.UserId, models)
print('done')
end)
There is no errors on the save script, but on the load script it fails to load in.
local DSS = game:GetService("DataStoreService")
local modelDataStore = DSS:GetDataStore("Models")
game.Players.PlayerAdded:Connect(function(player)
local models = modelDataStore:GetAsync(player.UserId)
for _, modelData in pairs(models) do
local targetModel = modelData.ModelName
local information = modelData.Position
local newModel = game.ReplicatedStorage:FindFirstChild(targetModel):Clone() --Script errors here.
local position = Vector3.new(information[1], information[2], information[3])
local lookVector = Vector3.new(information[4], information[5], information[6])
newModel:SetPrimaryPartCFrame(CFrame.new(position, position + (lookVector * 5)))
newModel.Parent = game.Workspace.Blocks
end
end)
Not sure if this is a problem with data not saving or whatever. Thoughts? Thanks, JailBreaker_13

4 comments
Try storing game.ReplicatedStorage:FindFirstChild(targetModel) in a value and then clone that value.
Sorry.. I dont follow lol, could you explain it simpler?
Like this: "local variable = game.ReplicatedStorage:FindFirstChild(targetModel)" Next line: "local newModel = variable:Clone()" if you want you could print variable to see what is in it. The value's name could be whatever you want obviously.
Worked! Want to lock the question? Lots of people have asked this question before.