I created a save/load script for Parts. Now i have to seperate the data to load it again how whould i do this?
Data format: Name: [Part], Position: [0, 0, 0] , Color: [0, 0, 0] , Material: [Enum.Material.Plastic]
how would you separate this to something like local Name,local Position, local Color and local Material?
I thought about doing something like string.sub
How I store the data:
function generateDataTable(player) local dataTable = {} for i,v in pairs(game.Workspace.TestFolder:GetChildren()) do table.insert(dataTable, ("Name: ["..tostring(v.Name).."], Position: ["..tostring(v.Position).."] , Color: ["..tostring(v.Color).."] , Material: ["..tostring(v.Material).."]")) return dataTable end
Hello, MageMasterHD!
I think you don't know lots about tables and dictionaries, that I think is what you want to do with your data, so I had to create it:
local dataTable = {} for i,v in pairs(game.Workspace.TestFolder:GetChildren()) do table.insert(dataTable, {["Name"] = v.Name, ["Position"] = v.Position, ["Color"] = v.Color, ["Material"] = v.Material}) --Created a Dictonary of the values end
Now you can do:
dataTable[1]["Name"] --This will give the name of the object 1 dataTable[1]["Position"] --This will give the Vector3 of the object 1 position dataTable[1]["Color"] --This will give the Color3 of the object 1
By Object 1
i'm telling about the object with index 1 (first object of the for loop)
Useful Links:
https://developer.roblox.com/articles/Table#Dictionaries
Hope this helps
Good Luck with your games