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)
YOU CANNOT STORE "userdata" VALUES (Vector3, Udim2, Faces, Color3, etc) use an lua "table" instead:
-- Replace all "Derrick.Position"s to: {X=Derrick.Position.X,Y=Derrick.Position.Y,Z=Derrick.Position.Z} -- and if you ever require referencing certain values: tablenamehere[X] tablenamehere[Y] tablenamehere[Z]
Just save the position of the part....? Either that or your question needs more detail.