Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I cant figure out how to make a saving checkpoint without leaderstats ?

I want a checkpoint that save your progress wherever you are (I only need one) but I dont want it to work on leader stats. I know your not suppose to request on this site but I have been working on this for about 45mins. If you cant do that, can you please give me an idea on how to do it. Thanks

2 comments

0

Are you trying to save when a player touches an object or simply their in-game location when they leave?

0

When they touch it the checkpoint saves and when you leave and join back you will be on it

1 answer

✓ Accepted answer

Since you cannot save an object to a DataStore, you instead can save its name, which is a string, and when the player loads back in, check that the part's name matches the name of the checkpoint.

If the names match, then you can use the :SetPrimaryPartCFrame() function to move the character model to the given location.

In the example below, the checkpoint part is in the workspace

Server Script inside Server Script Service

local DSS = game:GetService("DataStoreService")
local Storage = DSS:GetDataStore("CheckPointSystem")

game:GetService("Players").PlayerAdded:Connect(function(player)
	local objval = Instance.new("ObjectValue")
	objval.Name = "CheckpointData"
	objval.Value = nil
	objval.Parent = player
	
	local success, result = pcall(function()
		Storage:GetAsync(player.UserId)
	end)
	
	if not success then
		warn(result)
	else
		local LoadData = Storage:GetAsync(player.UserId)
		if LoadData ~= nil then
			objval.Value = workspace:WaitForChild(LoadData)
		end
	end
	
	player.CharacterAdded:Connect(function(character)
		repeat wait() until (character:FindFirstChild("HumanoidRootPart") ~= nil)
		
		if objval.Value ~= nil then
			character:SetPrimaryPartCFrame(objval.Value.CFrame + Vector3.new(0, 4, 0))
		end
	end)
end)

game:GetService("Players").PlayerRemoving:Connect(function(player)
	Storage:SetAsync(player.UserId, player.CheckpointData.Value.Name)
end)

Server Script inside Checkpoint

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		local checkpointData = player:WaitForChild("CheckpointData")
		if checkpointData.Value ~= script.Parent then
			checkpointData.Value = script.Parent
		end
	end
end)

Please note that if you use multiple checkpoints, they must each have a different name in order for this to work.

3 comments

0

Does the Checkpoint have to be named CheckpointData or just Checkpoint

0

The checkpoint name doesn't matter, as long as it is different from the names of any other checkpoints you may have

0

Great, Thanks for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.