This is supposed to be a DataStore script I did from a tutorial but it doesn't seem to work. Any idea what's wrong?
Here's part one of the script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("LolWhyDa") game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("IntValue", player) stats.Name = "leaderstats" local points = Instance.new("IntValue", stats) points.Name = "Points" local coins = Instance.new("IntValue", stats) coins.Name = "Coins" local key = "user-"..player.userId local savedValues = DataStore:GetAsync(key) if savedValues then --Save Format: {points, coins} points.Value = savedValues.Value[1] coins.Value = savedValues.Value[2] else local valuesToSave = {points.Value, coins.Value} DataStore:SetAsync(key, valuesToSave) end end)
Part 2, located in a seperate script
local DataStore = game:GetService("DataStoreService"):GetDataStore("LolWhyDa") game.Players.PlayerRemoving:connect(function(player) local key = "user-"..player.userId --Save key: {points, coins} local valuesToSave = {player.leaderstats.Points.Value, player.leaderstats.Coins.Value} DataStore:SetAsync(key, valuesToSave) end)
both scripts are in ServerScriptService.
I know thisis not much help but this is where you can learn it http://wiki.roblox.com/index.php?title=Data_store
With data stores it is dificult, but as johndeer said, that is the best place to start :/