So for three days now (Not on the whole game just the save & load) I've been working hard on a Roblox turn based RPG. It came to my attention players would need to save and load there game data. So I've read around on DataStores and how to convert CFrame values to a DataStore. But nothing seems to be working.
The Closest I've come to doing this sort of thing is this
- Have A ScreenGui in StarterGui
- In it I have a Save & Load Button.
- In the Save Button there is a Local script
The Local script is the following -
local saveButton = script.Parent
local loadButton = script.Parent.Parent.LoadButton
saveButton.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.SaveLocation.PlayerPosition.Value = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
end)
loadButton.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players.LocalPlayer.SaveLocation.PlayerPosition.Value
end)
Here is 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"
plr:WaitForChild("X").Value = plr.Character:WaitForChild("HumanoidRootPart").CFrame.x
plr:WaitForChild("Y").Value = plr.Character:WaitForChild("HumanoidRootPart").CFrame.y
plr:WaitForChild("Z").Value = plr.Character:WaitForChild("HumanoidRootPart").CFrame.z
end)
EDIT - The Local Script does save the CFrame then Load it when the button is clicked, it's the matter of having the SAME CFrame when you leave the game and then rejoin the game
This is my first post on ScriptingHelpers so if I said anything or did anything incorrectly above any feedback or help is appreciated. Thanks.

7 comments
Place your code in between the code block. The code block are the two squiggly lines you insert when clicking the blue Lua icon.
Sorry I'm a little confused on your response. Do you mean in studio or here on the forum?
Here in the question. Edit this post. Button is right below this comment section.
Put all in codebox: https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site
According to what I see here, you haven't actually saved or loaded anything
You make a datastore and a save variable, but they are never used. Are you sure this is your whole script?
Yes this is all I've done, am I missing something?