Hi! So i have a building game. There are worlds in the building game, sort of like Blockate. ([🌴] Blockate - Roblox) So each world has a numerical id, name, etc… all condensed. I want it so that there’s a menu, and once you create a world, it loads the world to the game.
Basically, i want a way to load data to a game, not player, but game.
a datastore key is just a string, you can make it whatever you want as long as it is within 50 characters
go nuts…(Documentation - Roblox Creator Hub)
example:
tostring(UserID)…“-”…tostring(buttonnumber)…“-”…“this text just because i can”
someone first created that world and lets call him the owner.
start your key with player.userid this makes sure no 2 players can own the same world.
now you get buttons, lets give every button a number 1 to 5
now you can add …“-”…tostring(buttonnumber)
after that i just added some text cuz… as long as you request the same key as to wich you set it you will get the data
if you want to make it fancy you can have a seperate datastores with all the names of the worlds etc.etc. to show on the button
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local success, err = pcall(function()
experienceStore:SetAsync("Player_1234", 50)
end)
if success then
print("Success!")
end
Load data
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local success, currentExperience = pcall(function()
return experienceStore:GetAsync("Player_1234")
end)
if success then
print("Current Experience:", currentExperience)
end
these are mentioned in the link I provided
or do you mean serialisation (transforming all the object in the world space to a savable string)?
which is not his original question
You can’t really… It depends. You would have to get the data every time the server launches. Also there’s Messaging service to communicate between servers. But using data stores, you can just not use userIds / player data, do your own system. You don’t NEED to have a player userId on a dataStore key.
When you do that, it’s for giving each player it’s “data id”.
Hey there.
ok am not sure if am right, but the best way to do this is by storing the location value, size value, material value and colour value inside a table and then add this table to a main table which conatins info of all tables(which are the infos of every part), If am right roblox datastores can store table values.
also u might want to add all the player’s blocks inside a model named after the player,for easy reading of which parts has been placed by which player.
Basically, it loads all the parts when someone joins. if antoher player joins, it just joins that server. every time someone clicks on a game, if there is not already a running instance of that game, it creates one with the data, and any changes will load the data to new instances, therefore, 1 server for game
First of all, you need a method to serialize the plot data. It’s hard to provide any suggestions on how to do this, since we don’t know how complex your plots/buildings are. I recommend this thread for developing a method fit for your game to do that: Saving plots on a datastore! - #2 by colbert2677
You’ll then need to also save the name: I would create a table, set the key in the datastore to the plot id, and have two values in the table: Name and Data.
For example:
local PlotDefaultData = {
Name = "New Plot";
Data = {
-- Your serialized data here
}
}
Then you could store data like such:
local ID = 001 -- Your plot ID here
local SerializedData = {} -- Your serialized data here
local PlotDataToSave = DefaultData
PlotDataToSave.Name = PLOT_NAME_HERE
PlotDataToSave.Data = SerializedData
pcall(function()
Datastore:SetAsync(ID, PlotDataToSave)
end)