Hello, I am currently working on a save script which works as planned but the only thing is, I keep getting a weird table looking thing. The data get correctly placed inside, but the table.insert is making a table go into another table. My goal is to be able to print the data inside the table successfully. Here is the table.insert part (this is in a for loop)
local data = {} for i, v in pairs(workspace.Parts:GetChildren()) do table.insert(data, i, { ["Name"] = v.Name, ["Properties"] = { ["Anchored"] = v.Anchored; ["CanCollide"] = v.CanCollide; ["Transparency"] = v.Transparency; ["BrickColor"] = v.BrickColor.Name; ["Material"] = v.Material.Value; ["Reflectance"] = v.Reflectance; ["X"] = v.CFrame.X; ["Y"] = v.CFrame.Y; ["Z"] = v.CFrame.Z; ["R_X"] = v.Orientation.X; ["R_Y"] = v.Orientation.Y; ["R_Z"] = v.Orientation.Z } }) end
The end result is:
--[[ [{"Properties":{"R_Y":45,"R_Z":11.25,"Z":45.25,"Material":256,"Transparency":0,"Y":0.5,"BrickColor":"Medium stone grey","Anchored":true,"X":32.70001220703125,"Reflectance":0,"CanCollide":false,"R_X":-11.25},"Name":"Part"}] ]]-- (there is 1 part in the model "Parts" in workspace, therefore only getting the information from 1 part. If there were 2 parts in the model, the table would be 2 repetitions of the table.insert)
I am wanting to remove the "[{" and make it "readable" by printing, such as
-- EXAMPLE (above) local dss = game:GetService("DataStoreService") local playerslot1 = dss:GetDataStore("playersave1") local player = game:GetService("Players").LocalPlayer local datastore_data = playerslot1:GetAsync(player.UserId) local player_data = httpservice:JSONEncode(datastore_data) print(player_data["Name"], player_data["Properties"]["Material"])
To clarify, the example above is what I want the "reading" of the data process to be like, nice, short, straight to the point, and simple.
Any solutions appreciated!
Using unpack(tbl, index, #list) should work.