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

How do I save player data e.g amount of points on a leaderboard?

Asked by 7 years ago
Edited 7 years ago

How do I save the data on a leaderboard for example, the amount of points so that when the player rejoins, they still have their amount of points they earned previously. In my game, I made a leaderboard in my playermanager script where I have code on what happens to the player when they join the game(Capture The Flag Game) and what happens when they capture the flag and how it displays on the leaderboard. What do I have to edit in the code to make sure the amount of captures the player makes in the game is saved on the leaderboard so that when they rejoin they have that data of the amount of captures they make still saved on the leaderboard

My Player Manager/Leaderboard Script:

001local PlayerManager = {}
002 
003-- ROBLOX Services
004local Players = game.Players
005local PointsService = game:GetService('PointsService')
006 
007-- Game services
008local Configurations = require(game.ServerStorage.Configurations)
009local Events = game.ReplicatedStorage.Events
010local ResetMouseIcon = Events.ResetMouseIcon
011local TeamManager = require(script.Parent.TeamManager)
012local DisplayManager = require(script.Parent.DisplayManager)
013 
014-- Local variables
015local PlayersCanSpawn = false
View all 100 lines...

My datastore My datastore script:

01local DSService = game:GetService('DataStoreService'):GetDataStore('Hamburger223232')
02game.Players.PlayerAdded:connect(function(plr)
03 
04    local uniquekey = 'id-'..plr.userId
05    local leaderstats = Instance.new('IntValue',plr)
06    local savevalue = Instance.new('IntValue')
07    leaderstats.Name = 'leaderstats'
08    savevalue.Parent = leaderstats
09    savevalue.Name = 'Captures'
10 
11    local GetSaved = DSService:GetAsync(uniquekey)
12    if GetSaved then
13        savevalue.Value = GetSaved[1]
14    else
15        local NumbersForSaving = {savevalue.Value}
View all 26 lines...

I tried adding a separate datastore on a different script but it didn't work so I am hoping that I could add some code to this script to make sure the amount of captures the player makes is saved on it so that the player can use its captures to buy things in the game etc.

Thank You And Help is Appreciated

0
I can see how you attempted to use AlvinBloxx's code Lmao, But I don't see any ways how this won't work, the script looks fine greatneil80 2647 — 7y
0
Only the first script is confusing greatneil80 2647 — 7y
0
OK aspiringstar346 8 — 7y

Answer this question