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

How do I add DataStore to a leaderboard?

Asked by 10 years ago

I am trying to save a single stat using datastore, but I have read the wiki and I am still confused.. I have been trying to do this for days on days.. I just want to learn how to save a single stat. That stat would be points. Here is a little leaderboard I made. Could anyone explain on how to use DataStore?

local playerStats = {} --this keeps a list of the stats for each player that enters the game

 game.Players.PlayerAdded:connect(function(player) --Added function
     local leaderstats = Instance.new("Model", player) --Make leadeerstats I am storing it as a model inside the player so it's easier to edit.
     leaderstats.Name = "leaderstats" --Change the name...
  local Points = Instance.new("StringValue", leaderstats)
   Points.Name = "Points"
   Points.Value = 0



  local grouprank = Instance.new("StringValue", leaderstats) --assign the variable
       grouprank.Name = "Rank" --set up value
       local rank = player:GetRoleInGroup(1066846) --Get the group rank from group 
     local rankn = player:GetRankInGroup(1066846)
     grouprank.Value = rank --Then assign them the rank

        if rankn == 75 then --If user is rank number 75, assign them to team name DJ
        local team = game:GetService("Teams") --Get the Team service
        player.TeamColor = team.DJ.TeamColor-- change the errors to whatever Change the players team to DJ, Should I do team color? problem could be right here
        playerStats[player] = leaderstats 
     end
end)

--[[
-refrences-

leaderstats          Model inside the player holding the values.
Points               String value in the leaderstats model  
Rank                 String value in the leaderstats model  


--]]

Answer this question