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

How do you make a checkpoint where when you leave and rejoin you spawn back at the same spot?

First i put the teams and make spawns that have the teams names then i make the color same to the team color and turned off Neutral and turned on AllowTeamChangeOnTouch I also put the spawns into folders. I add this script in to ServerScriptService. (Only everything works BUT saving the players spot when leaving)

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("ObbyDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local data
	
	local success, errorMessage = pcall(function()
		data = DataStore:GetAsync(player.UserId.."-stasge")
	end)
		
	if success then
		print("Success")
		if data then
			player.Team = game.Teams[data]
		else
			player.Team = game.Teams.Stage1 
		end
	else
		print(errorMessage)
		player.Team = game.Teams.Stage1
	end
	
	player:LoadCharacter()
	
end)

game.Players.PlayerRemoving:Connect(function(player)
	local teamName = player.Team.Name
	
	local success, errorMessage = pcall(function()
		DataStore:SetAsync(player.UserId.."-stage",teamName)
	end)
		
	if success then
		print("All went well")
	else
		print(errorMessage)
	end
end)

I don't get what is wrong.

3 comments

0

Maybe try it on published game instead of Studio Testing mode ?

0

OHHHHH

0

isn't this from AlvinBlox, because this is an exact copy...

1 answer

✓ Accepted answer

Line 8, you have "-stasge", but you saved it to be "stage" on line 31.

1 comment

0

ye

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