Datastoring for singleplayer story games

I have been recently working on a story game, however, due to it’s length, not many people would be able to complete it all in one sitting, therefore I have thought of creating a datastore which can:
Save the progress in quests (meaning that, all the quests you have finished, cannot be redone) , i think i have the part where you cannot redo the quest down, but i don’t know how that will go with saving and datastores.

Save cutscene progress (meaning you won’t have to redo a cutscene) (Completed)

Location saving (to get the exact location of the character, save it there, and then be able to sucessfully load the character to that location or similar) This may cause issues, or open up possibilities for glitches, which is why, along with this i’ve made an experimental “Get Unstuck” option in the menu, which will bring you to your closest checkpoint. (Get Unstuck button Completed)

This idea has sprung from the preexisting game “Loomian Legacy” which seems to pull it off really well. I have an understanding of datastores, so a simple idea of what services to get, and what data to grab would still help, as i’m kind of unsure how to approach these and be able to put them together in a way that wouldn’t cause too many issues.
I thank you for your time :slightly_smiling_face:

What exactly do you need help with?

The general question would be how exactly would i go about saving a character in place (my biggest issue for now) so that it could be loaded in there for the future. (Sorry if it was unclear)

Maybe save their CFrame in a Vector3 and reload it?

I had a short think about this, and I feel like this would be a simple way to do it, I was sitting here making rough plans for how I’d do it, and alot of them weren’t this simple, I’ll have a go at that!

You can try using this Value

1 Like

This seems to be it ! Saving a Vector3 value seems to be the most efficient way to achieve this! Thanks for your suggestion

1 Like

This will work:

--//Services
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")

--//Variables
local PlayerDataStore = DataStoreService:GetDataStore("PlayerDataStore")

--//Functions
Players.PlayerAdded:Connect(function(player)
	local PlayerData = PlayerDataStore:GetAsync(player.UserId)

	player.CharacterRemoving:Connect(function(character)
		--//Datastoring
		local DataTable = {
			character.HumanoidRootPart.Position.X,
			character.HumanoidRootPart.Position.Y,
			character.HumanoidRootPart.Position.Z,
		}

		local success, errorMessage = pcall(function()
			PlayerDataStore:SetAsync(player.UserId, DataTable)
		end)

		if not success then
			print(errorMessage)
		end

		--//Debugging
		print(DataTable)
	end)

	--//Spawns player at their last spawn
	if PlayerData then
		player.CharacterAdded:Wait()
		task.wait(0.1)
		player.Character.HumanoidRootPart.Position = Vector3.new(PlayerData[1], PlayerData[2], PlayerData[3])
	end
end)
1 Like

This might help

1 Like

Break the story into segments, and when the player leaves save either the segment or the cframe of the character. Then when the player loads in again just continue from that saved segment.

Had a read, that was incredibly informative, thanks for that

Check my code, it saves your location when you leave.