I'm trying to save the value when players leaves, and then load that data when a player joins. How am I supposed to do this?
DataStore = game:GetService("DataStoreService")
game.Players.PlayerRemoving:connect(function(plr)
local value = plr.PlayerGui:WaitForChild("RankGui").Rank.Rank
local key = "Rank_" .. plr.userId
DataStore:SetAsync(key,value.Value)
end)
local DataStore = game:GetService("DataStoreService"):GetGlobalDataStore("Rank")
game.Players.PlayerAdded:connect(function(Player)
local PlayerKey = "Rank_" .. Player.userId
local leaderstats = Instance.new("IntValue", Player)
leaderstats.Name = "leaderstats"
local Rank = Instance.new("StringValue", leaderstats)
Rank.Name = "Rank"
if DataStore:GetAsync(PlayerKey) ~= nil then
Rank.Value = DataStore:GetAsync(PlayerKey)
else
Rank.Value = "Civilian"
end
end)
Where it says, GetGlobalDataStore, how does it know that it's called "Rank"? I never defined it. However, data never loads anyways. Also, whenever i leave, I end up with Civilian.

2 comments
Have you looked at this? http://wiki.roblox.com/index.php?title=Saving_Player_Data
i dont understand it.