Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Transferring Models between places?

Asked by 9 years ago

I was reading on the Roblox Wiki about the new multi place games... And I was wondering if its possible to save objects that players built in one place and spawn it in another place.

I haven't tried coding anything so far... My video card went up in my gaming pc so I'm currently awaiting the delivery of another one. However I did read in the Wiki and there's some part about not being able to store instances but creating a function that adds them to a table.

So my question is... Is it possible to transport player built models from one place to another using Data Stores?

2 answers

Log in to vote
1
Answered by
Tuneable 100
9 years ago

Yes it is very possible. The best way to accomplish this is to create a table of properties to save. Remember that you cannot save any type of userdata either, so properties like CFrame and BrickColor will have to be saved a different way.

Here is some example code

local function PartToTable(Part)
    local Table = {} -- table that will hold all the properties
    local NormalProperties = {"Transparency", "CanCollide"} -- Non userdata properties of a part. I just added a couple

    for i,v in pairs(NormalProperties) -- loop through the basic properties
        Table[v] = Part[v] -- Add to table
    end

    -- Custom properties

    Table["CFrame"] = {Part.CFrame:components()}
    Table["BrickColor"] = Part.BrickColor.Name
    return Table
end

local function TableToPart(Table)
    local Part = Instance.new("Part")

    for i,v in pairs(Table) do
        Part[i] = v -- set the basic properties
    end

    Part.CFrame = unpack(Table["CFrame"]) -- set the userdata properties
    Part.BrickColor = BrickColor.new(Table["BrickColor"])'

    return Part
end

Let me know if you have any questions about the example code I provided.

0
Okay I haven't coded roblox a day in my life lol. But I'm going to try and decipher this code.... User#5748 20 — 9y
0
Oh well I didn't really write it for use so it might have some errors. I also didn't write anything with datastores because I assumed you knew how to do that yourself. Tuneable 100 — 9y
0
So I can understand what I'm looking at. You have two functions one that saves the part to a table and one that creates a part from a table. Your converting the parts properties that you can save to the primary table and creating additional tables for the ones you cannot... You then retrieve the part in the function that generates the part and set its properties... As I can see your using a for lo User#5748 20 — 9y
0
I don't feel like retyping that last part so..... Would coding this way be enough to handle more then 100+ parts to generate a single model from a table? And if you call a function before saving the table could you possibly save user data? Forgive me I can't run any tests at the moment cause my PC has 64 mb of video memory. User#5748 20 — 9y
View all comments (2 more)
1
I'm not sure if this would be able to handle 100+ parts to be completely honest. There's no way to save a userdata value directly. But you can do things like save "Bright red" instead of BrickColor.Red(). Tuneable 100 — 9y
0
So if I wanted to save models of that caliber it'd be best to use the Data Persistence save instance. User#5748 20 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Try to get this sample

http://www.roblox.com/Create-Place-Lobby-place?id=146051778 http://www.roblox.com/Create-Place-Zone-place?id=146059799

And edit it..... i tried it then it works......

finished product: http://www.roblox.com/Build-your-own-Universe-Finished-Game-place?id=154470806

Answer this question