So I've been working on a Roblox RPG and for four days I've been trying to make a save and load system. But I've had no success. I'm trying to use a Script in ServerScriptService to give the player a CFrame value and when the player presses a save button, the CFrame updates and when they leave it stays the same. I've looked all over to find any answer but no success in what I'm trying to do. So far this is what I have in my DataStore Script.
local DataStore = game:GetService("DataStoreService")
local save = DataStore:GetDataStore("SavePos")
game.Players.PlayerAdded:Connect(function(plr)
local spot = Instance.new("Folder",plr)
spot.Name = "SaveLocation"
local pos = Instance.new("CFrameValue",spot)
pos.Name = "PlayerPosition"
end)
This is all I have, there used to be more but I deleted it since it wouldn't work. Any help is appreciated, thank you.
EDIT - So with the buttons I've made a little test to get the buttons from PlayerGui,
local DataStore = game:GetService("DataStoreService")
local save = DataStore:GetDataStore("SavePos")
local saveButton = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton
local loadButton = game.Players.LocalPlayer.PlayerGui.ScreenGui.OtherButton
game.Players.PlayerAdded:Connect(function(plr)
local spot = Instance.new("Folder",plr)
spot.Name = "SaveLocation"
local pos = Instance.new("CFrameValue",spot)
pos.Name = "PlayerPosition"
pos.Value = save:GetAsync(plr.UserId) or 0
saveButton.MouseButton1Click:Connect(function()
end)
loadButton.MouseButton1Click:Connect(function()
end)
end)
Now I want it to update pos.Value when saveButton is clicked on the HumanoidRootPart.CFrame, then maybe save could be used, not sure how really though, DataStores are not my strong suite. Then when you leave and come back, pressing loadButton would then load your position etc.

3 comments
This system can be very problematic if the map changes. A player could be positioned within a house that changes position. I would just spawn the player at the closes spawn position ingame.
So make a system where when the player leaves, he'll rejoin at the same spawn?
dude,save the value as an int,then just use that int inside the CFrame,like CFrame.new(num),