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

Saving DATA Help?

So im trying to make a character customization,You only chose your character ONCE,So character customization will only appear for the first time you play,Then it saves your customization to somewhere forever,Then your character loads everytime from your custom data,+How would i achieve this?

Im aware of DataKeys or whatever,But i dont know how..

2 answers

✓ Accepted answer

http://wiki.roblox.com/index.php?title=Data_store

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataTest")
 
game.Players.PlayerAdded:connect(function(player) -- Player entered

	local key = "user_" .. player.userId -- Gets there userId for new or old storage

	DataStore:UpdateAsync(key, function(oldValue) -- Starts updating there stat's
		local newValue = oldValue or 0 -- Finds or make's there data
		newValue = newValue + 50 --Add's 50 to newValue or 0
		print(newValue) -- Just for you to see the script updated c:
		return newValue -- Saved
	end)
end)

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