I'm trying to make a datastore that saves the position of a part, how do I do this?
local DataStore = game:GetService("DataStoreService"):GetDataStore("DerrickPosition")
local Derrick = workspace:WaitForChild("Derrick")
game.Players.PlayerAdded:connect(function(plr)
local uniquekey = "id"..plr.userId
--LeaderStats
local leaderstats = Instance.new("IntValue", plr)
leaderstats.Name = "leaderstats"
local Money = Instance.new("IntValue", leaderstats)
Money.Name = "Money"
--Saving
local key = "user-"..plr.userId
local saveValue = DataStore:GetAsync(key)
if saveValue ~= nil then
-- Save Format: {money, Position} Tables
Money.Value = saveValue[1]
Derrick.Position = saveValue[2]
else
local valueToSave = {Money.Value, Derrick.Position}
DataStore:SetAsync(key, valueToSave)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local key = "user-"..plr.userId
local valueToSave = {plr.leaderstats.Money.Value, Derrick.Position}
DataStore:SetAsync(key, valueToSave)
end)

1 comment
You haven't tried to save it, so don't expect any scripts.