This script stores a data value in the player when they join, and updates it depending on the the value stored in a DataStore.
Output: NumberValue is not a valid member of player
local DataStore = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(player)
local key = "user_"..player.userId
Instance.new("NumberValue",game.Players:FindFirstChild(player))
if DataStore:GetAsync(key) == nil then
game.Players:FindFirstChild(player).NumberValue.Value = 0
DataStore:SetAsync(key,0)
else
game.Players:FindFirstChild(player).NumberValue.Value = DataStore:GetAsync(key)
print("Got here")
end
end)
Thanks, MD

1 comment
Thanks!