This is just a quick question, so how would I be able to reach the second table of one Data in a datastore? There are 2 tables. The first table is the part where it says “Tall wall”, the second is where it says “Color”. What I’m trying achieve is a data saving/loading models with the BrickColorValue, I couldn’t figure out how to merge this into one table, so I wanna do it this way. Any suggestions?
I’ve tried table.find, but it won’t detect the second table…
function Placement.fromSerialization(canvasPart, data)
local self = Placement.new(canvasPart)
local canvasCF = canvasPart.CFrame
data = data or {}
print(unpack(data))
for cf, name in pairs(data) do
local model = furniture:FindFirstChild(name)
if (model) then
local components = {}
local components2 = {}
for num in string.gmatch(cf, "[^%s,]+") do
components[#components+1] = tonumber(num)
end
self:Place(model, canvasCF * CFrame.new(unpack(components)), false)
print(model.Parent)
print(unpack(components))
print"loaded data"
end
end
return self
end
I’m just so lost here, I can’t seem to load the second table.
Are you passing the data from DataStore:GetAsync() directly into the module as data? If so, I think data[2] would be your color. Can you do print(name) right before local model = ?
Okay so, I’ve been able to figure out the colors, however whenever I try to unpack the components and print it, it says
“M e d i u m s t o n e g r e y”
Instead of “Medium Stone Grey”
How would I prevent it from spacing?
if name=="Color" then
local components = {}
for num in string.gmatch(cf, ".") do
components[#components+1] = tostring(num)
end
print(unpack(components))
model.BrickColorVal.Value=BrickColor.new(unpack(components))
end
function Placement.fromSerialization(canvasPart, data)
local self = Placement.new(canvasPart)
local canvasCF = canvasPart.CFrame
data = data or {}
print(unpack(data))
for cf, name in pairs(data) do
print("Printing"..name)
local model = furniture:FindFirstChild(name)
if (model) then
local components = {}
local components2 = {}
for num in string.gmatch(cf, "[^%s,]+") do
components[#components+1] = tonumber(num)
end
self:Place(model, canvasCF * CFrame.new(unpack(components)), false)
print(model.Parent)
print(unpack(components))
print"loaded dat"
end
if name=="Color" then
local components = {}
for num in string.gmatch(cf, ".") do
components[#components+1] = tostring(num)
end
print(unpack(components))
model.BrickColorVal.Value=BrickColor.new(unpack(components))
end
end
return self
end