Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you save buildings and then load them?

I'm making a tycoon-like game where the user gets to pick what room they want to place down. I have a grid system and when they click on a GUI button, the room appears on their mouse and they can place it wherever. I've tried using data persistence but I understand that that's depreciated and I can't figure out how to use data stores to store buildings instead of data.

I've seen somewhere else that a good idea would be to locate the user's purchases and then save the name of the purchases, put it in a table, convert them to strings and then use a data store. I'm not really sure how to do this and when you are loading in the buildings, how does the game know where to place them or do I need to store all of the details of the purchases, including size and colour, etc...

1 answer

You could put it all into 1 model object and then store it in ReplicatedStorage or in ServerStorage.

Once you have done that simply do:


buildings = {"Put all of your buildings that you have saved in here"}

local building = game.ReplicatedStorage[modelNames[Index]]:Clone()

-- Index = Whatever one you want to access
--[==[

e.g.

Indexes = {"Hello","me"}

print(Indexes[1])

-- Prints "Hello"

print(Indexes[2])

--Prints "me"

]==]

building.Parent = game.Workspace

-- Then edit stuff down here. E.g. who built it

local Owner = Instance.new("StringValue")

Owner.Name = "Owner"

Owner.Value = builder.Name

Owner.Parent = building

good thing is: if you're always going to be using the same buildings you can do this as ServerStorage/ReplicatedStorage is the same on every game, only issue is you might need to update every server once you add a new one and you can't save user stuff like this for all servers.

This discussion is preserved as it was. New answers, comments, and votes are closed.