Why? I converted it do a string.
local Data = {
['Name']=objects.Name,
["Pos"] = tostring(plot.CFrame:ToObjectSpace(objects.CFrame)),
["Color"] = {
["R"] = objects.Color.R,
["G"] = objects.Color.G,
["B"] = objects.Color.B
}
}
for i,v in pairs(Data) do
plotdata[i] = v
end
Try This
Got more progress, I think it works, but, now when cloning the object, it says âArgument 1 missing or nilâ so the name apparently probably isnât saving.
No, after checking it does save the name, just isnât loading.
Try changing the âNameâ variable to something else cause it might be interfering with your code.
Are you indexing the table by using plotdata.Name or plotdata[âNameâ]?
.Name, but also, now nothing is saving.
Donât do .Name, whenever your referencing a dictionary use [âNameâ]
local loadedmodel = game.ReplicatedStorage.BuildableObjects:FindFirstChild(saved['Name']):Clone()
if loadedmodel then
print(saved.Pos)
loadedmodel.BrickColor = BrickColor.new(saved['Color'].R,saved['Color'].G,saved['Color'].B)
loadedmodel.Parent = plotbeingviewed
loadedmodel.CFrame = tonumber(saved.Pos) * plotbeingviewed.CFrame
end
Try This
Didnât work, I donât know what to do.
Maybe it just a issue with your datastore script, try using Profile Service by Loleris
game.Players.PlayerRemoving:Connect(function(player)
local plot = game.Workspace.Plots:FindFirstChild(player.PlotOwned.Value)
local plotdata = {
}
if plot then
if game.Workspace.Plots:FindFirstChild(player.PlotOwned.Value) then
for i, objects in ipairs(plot:GetChildren()) do
if objects:IsA("BasePart") and objects.Name ~= "Box" then
local Data = {
['Name']=objects.Name,
["Pos"] = tostring(plot.CFrame:ToObjectSpace(objects.CFrame)),
["Color"] = {
["R"] = objects.Color.R,
["G"] = objects.Color.G,
["B"] = objects.Color.B
}
}
for i,v in pairs(Data) do
plotdata[i] = v
end
end
end
end
end
player.PlotOwned.Value = ""
local id = "Player_" .. player.UserId
local success, err = pcall(function()
plotstore:SetAsync(id,plotdata)
end)
if success then
print("saved")
else
print("no")
print(err)
end
end)
If this doesnât work, it most likely your datastore script
Yeah didnât work, whatever. Iâll just work on it another time.
Change your DataStore script with Loleris, Profile Service
local Data = {
['Name']=objects.Name,
["Pos"] = tostring(plot.CFrame:ToObjectSpace(objects.CFrame)),
["Color"] = {
["R"] = objects.Color.R,
["G"] = objects.Color.G,
["B"] = objects.Color.B
}
}
table.insert(plotdata,Data)
Oh found the issue, didnât realize you had multiple datas you were saving. Now when you are adding the parts loop through the plotdata first then you can index each of it.
for i,v in pairs(saved) do
local loadedmodel = game.ReplicatedStorage.BuildableObjects:FindFirstChild(v['Name']):Clone()
if loadedmodel then
print(v.Pos)
loadedmodel.BrickColor = BrickColor.new(v['Color'].R,v['Color'].G,v['Color'].B)
loadedmodel.Parent = plotbeingviewed
loadedmodel.CFrame = tonumber(v.Pos) * plotbeingviewed.CFrame
end
end
There you go
Thanks, the data saving works perfectly, however the CFrame is still broken, we need a CFrame expert, lol.
Does the CFrame save correctly? Maybe the issue stems from how itâs being applied?
How much âoffâ is the CFrame? Is it a slight deviation/rotation or is it literally loading on the wrong side of the map?
Note that CFrame has some very exclusive math operations (because theyâre being represented with matrices or quaternions or some other weird mathematical data structure that Iâm not qualified to talk about) so if youâre not careful youâll end up making silly mistakes, for example, cframe1 * cframe2
is NOT the same as cframe2 * cframe1
Furthermore, Iâm not exactly sure why itâs doing this compound assignment; what is cube.CFrame before you try to multiply it with plot.CFrame? What and why is there a pre-set CFrame for the cube? Ideally, it should be the other way around where the objectâs position is an offset of the plot, so something like
cube.CFrame = plot.CFrame * placementOffset --placementOffset being a CFrame calculated prior to saving
LoadCFrame.rbxl (33.9 KB)
local base = workspace.Plot.Base
local loadBase = workspace.LoadPlot.Base
for _, p in pairs(workspace.Plot:GetChildren()) do
if p.Name == "Base" then continue end
local partCFrame = base.CFrame:ToObjectSpace(p.CFrame) -- save this
local loadPart = p:Clone()
loadPart.CFrame = loadBase.CFrame:ToWorldSpace(partCFrame) -- load like this
loadPart.Parent = workspace.LoadPlot
end
I tried it, now it says argument 2 missing or nil.
works fine in the rbxl file, learn to debug your stuff