"how to make part save roblox studio" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "how to make part save roblox studio" answered properly. Developers are finding an appropriate answer about how to make part save roblox studio related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like how to make part save roblox studio. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on how to make part save roblox studio.
how to make part save roblox studio
local module = {}
local HttpService = game:GetService("HttpService")
local Properties = {
Part = {"Name", "Position", "Size", "Transparency", "BrickColor", "CanCollide", "CFrame", "Anchored", "Shape", "Material"},
Decal = {"Name", "Texture", "Transparency", "Face", "Color3"}
}
function Serialize(prop)
local typ = typeof(prop)
local r
if typ == "BrickColor" then
r = tostring(prop)
elseif typ == "CFrame" then
r = {pos = Serialize(prop.Position), rX = Serialize(prop.rightVector), rY = Serialize(prop.upVector), rZ = Serialize(-prop.lookVector)}
elseif typ == "Vector3" then
r = {X = prop.X, Y = prop.Y, Z = prop.Z}
elseif typ == "Color3" then
r = {Color3.toHSV(prop)}
elseif typ == "EnumItem" then
r = {string.split(tostring(prop), ".")[2], string.split(tostring(prop), ".")[3]}
else
r = prop
end
return r
end
function Deserialize(prop, value)
local r
if prop == "Position" or prop == "Size" then
r = Vector3.new(value.X, value.Y, value.Z)
elseif prop == "CFrame" then
r = CFrame.fromMatrix(Deserialize("Position", value.pos), Deserialize("Position", value.rX), Deserialize("Position", value.rY), Deserialize("Position", value.rZ))
elseif prop == "BrickColor" then
r = BrickColor.new(value)
elseif prop == "Color" or prop == "Color3" then
r = Color3.fromHSV(unpack(value))
elseif prop == "Material" or prop == "Face" or prop == "Shape" then
r = Enum[value[1]][value[2]]
else
r = value
end
return r
end
function InitProps(objects)
local tableToSave = {}
for _, obj in pairs(objects) do
local class = obj.ClassName
local t = tableToSave[class]
if not(t) then
tableToSave[class] = {}
t = tableToSave[class]
end
local add = {}
for _, Prop in pairs(Properties[obj.ClassName]) do
add[Prop] = Serialize(obj[Prop])
end
local children = obj:GetChildren()
if #children > 0 then
add["Children"] = InitProps(children)
end
table.insert(t, add)
end
return tableToSave
end
local function Create(parent, t)
for class, _ in pairs(t) do
for _, obj in pairs(t[class]) do
local object = Instance.new(class)
for prop, value in pairs(obj) do
if prop ~= "Children" then
object[prop] = Deserialize(prop, value)
else
Create(object, value)
end
end
object.Parent = parent
end
end
end
function module.Encode(objects)
return HttpService:JSONEncode(InitProps(objects))
end
function module.Decode(dic, slot)
local t = HttpService:JSONDecode(dic)
Create(slot, t)
end
return module
Source: devforum.roblox.com
All those coders who are working on the Whatever based application and are stuck on how to make part save roblox studio can get a collection of related answers to their query. Programmers need to enter their query on how to make part save roblox studio related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to make part save roblox studio for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of how to make part save roblox studio while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "how to make part save roblox studio". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to make part save roblox studio resolved professionally and stay updated to the latest Whatever updates.