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

When players rejoin the game, why do they not respawn at the last checkpoint they touched?

I don't understand this. I have recently started scripting a couple of weeks ago, so as a new scripter, I really need help on making this part. Once I have that script down (thanks to whoever helps me), I will have a cool obby, or at least an obby that isn't like those escape from school obbies that make you respawn at the beginning when you rejoin the game

2 comments

0

This is for helping people with script errors not having people making u scripts!

0

Its called scriptinghelpers, its in the name. He needs help with a script, ill provide it.

1 answer

Hello! To save data across players sessions, we use something called "DataStoreService". This is basically a free database provided to us from roblox. Since you didnt give too much detail in how the obby is configured, I am going to give you the base for datastore scripts.

DS = game:GetService("DataStoreService"):GetDataStore("PlayerLevel")--This is the name of the data store that we will store our data in

game.Players.PlayerAdded:Connect(function(plr)
	local Data = DS:GetAsync(plr.Name..plr.UserId) --Attempting to get existing data from the new player
	if not Data then --If this is the players first time playing, put them at level 1
		Data = 1
	end
	--From here you can make you own code to move the player to the spawnpoint.  Refer to the variable "Data" as the current level they are on!
end)
 
game.Players.PlayerRemoving:Connect(function(plr)
	local level = *Players Current Level* --Getting the players current level
	pcall(function() --Pcall prevents the script from breaking in case of an error
		DS:SetAsync(plr.Name..plr.UserId,level) --The actual line that will update the data under the players name
	end)
end)

If you have any questions, feel free to ask!

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