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

How to save parts put in by other users (in between servers) with DataStores? (Roblox)

Asked by 5 years ago
Edited 5 years ago

So, I am trying to make an Anarchy game inspired by Minecraft's Famous 2B2T. The main effect I am trying to get here is for people's creations (with f3x or btools preferably ) to stay in the server forever, even with no server running. Having tried / having failed multiple different ways, attempting to get the ruins effect (building / greifing over time to make a vast world) I am almost giving up, can't find something working on the RBLX DevForum either.. (Can't even post there). How can I make this work? (Posting the code for the script directly would be preferred by me, so I can just copy it but it is alright if not, suggestions welcome!)

This is my current code:

local ds = game:GetService("DataStoreService")

DataStore = ds:GetDataStore("worldparts")

function save(a)

DataStore:SetAsync("mySavedModel", {Id = "MyModel", Position = {X = 10, Y = 0.5, Z = -6}})

end

--loader test

if workspace.atld.Value == false then

workspace.atld.Value = true

local data = DataStore:GetAsync("mySavedModel")

local newModel = game.ReplicatedStorage.Models:FindFirstChild(data.Id):Clone() -- Clones the template model. data.Id is 'MyModel'

newModel:SetPrimaryPartCFrame(CFrame.new(data.Position.X, data.Position.Y, data.Position.Z)) -- Moves the cloned model somewhere defined by our saved data.

newModel.Parent = workspace

end

game.Workspace.workspacestuff.Changed:Connect(save)

Also, workspacestuff is a model (located in the workspace)

0
have u even tried going to the blog and clicking on the placement blog? cause that is literally a saving sandbox that you need. greatneil80 2647 — 5y
0
You should be putting all the parts in a table and saving when the server closes. If you have two servers, it'll cause problems, but if you apply it correctly you should be fine. Tip: store numbers as rounded string values to reduce the data values saved. PhantomVisual 992 — 5y

Answer this question