Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a player have Stats if they are new too the game?

Asked by 4 years ago

My game is a cross-server game and I am mainly focusing on Datastores. For new players, How would i go on adding Data to their values?

_G.Data = {
koins = 500,
level = 1,
rank = "Bronze",
print('make sure to add jersey'),
--Helmet = (link)
--Helmet.Name = "Helmet",
--local mouthp = Instance.new("MeshPart",Data),
--mouthp.Name = "Mouthpiece",
xp = 1
}





local DSS = game:GetService("DataStoreService")

local datastore = DSS:GetDataStore("YourChampion")


for index,value in pairs (_G.Data) do
    datastore:UpdateAsync(index, function() return value end) -- index will be our 
end 


function generateDataKey(player)
    local ret = "Champion:"..player.userId
    print(ret)
    return ret
end

function generateDataTable(player)
    local dataTable = {
        koins = player.PlayerGui.Nice.Data.koins.Value,
        level = player.PlayerGui.Nice.Data.Level.Value,
        xp = player.PlayerGui.Nice.Data.xp.Value,
        rank = player.PlayerGui.Nice.Data.Rank.Value
    }
    return dataTable
end

Answer this question