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

How can I make a game save players progress?

How could I save someone's progress including their look if I already have a default look for new players that is given on join? I'm just wondering how this could possibly be done. I don't want to be requesting anything.

1 comment

0

DataStoreService?

1 answer

✓ Accepted answer

Check out the wiki page for DataStoreService, http://wiki.roblox.com/index.php?title=API:Class/DataStoreService.

This script isn't efficient, but it's an example of how you would use the service to do this.

local datastore = game:GetService("DataStoreService"):GetDataStore("StoreName")


game.Players.PlayerAdded:connect(function(player)
	repeat wait() until player.Character
	local character = player.Character
	
	if character:FindFirstChild("Shirt") then
		 shirt = character.Shirt.ShirtTemplate
	end

	if character:FindFirstChild("Pants") then
		 pants = character.Pants.PantsTemplate
	end

	if character:FindFirstChild("ShirtGraphic") then
		 shirtg = character.ShirtGraphic.Graphic
	end		
			
	local key = "user-" .. player.userId
	
	local storeditems = datastore:GetAsync(key)
	
	if storeditems then
		shirt = storeditems[1]
		pants = storeditems[2]
		shirtg = storeditems[3]
	else
		local items = {shirt, pants, shirtg}
		datastore:SetAsync(key, items)
	end
end)

game.Players.PlayerRemoving:connect(function(player)
	local items = {shirt, pants, shirtg}
	local key = "user-" .. player.userId
	
	datastore:SetAsync(key, items)
end)

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