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

DataStore Save Parts in area and load parts in area ( like build and race)?

Asked by 6 years ago

4 Teams 4 building areas Click save or load on GUI or something Grabs parts in your area to save when you click save Load will load parts in area but I need it to be the right garage for the team your in so if you save in green and leave and come back and your in yellow team it won't spawn the parts in the green area.

A point in the right direction would be nice I haven't been able to find much on saving models

local DS = game:GetService('DataStoreService'):GetDataStore(tostring(Player.userId));
local stable = {};
for i=1,#list do
stable[i] = {list[i].Name,{list[i]:GetPrimaryPartCFrame():components()}};
end;
DS:SetAsync('Build', stable);

This is what I seen but doesn't really explain much.

0
If you are new to scripting then do not attempt things you do not understand. Ability comes with time, be patient User#21908 42 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Ok there are some big problems in your code that need addressed. First of all, on line one you are creating a new datastore for every player that joins. Don't do that. Instead name it something fitting with a string. Like for example: local DS = game:GetService('DataStoreService'):GetDataStore('Build'). On line six when you are using SetAsnyc the first argument of that should be the data that you are saving. The second argument should be the players UserId. Now it's not very clear to me from your question what you are trying to do so if this following part of my question does not work for you I am sorry. If all models already exist in the game, just put an IntValue inside each of them and give each model a unique id. The loop through all the models the player has and save the ids of each of them. Then when they rejoin the game loop through all the models they can get and check their ids against the ids in the table you got from the datastore. I am really unsure what you are trying to do but I hope this helps a little.

0
The code was just an example. I want it to save what the player has build in the area and load it in new area when they want to load it when they join namerplz 42 — 6y
Ad

Answer this question