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

Can I have help with my leaderboard stats please?

Asked by 2 years ago
Edited 2 years ago

Hey, I am creating an obby but I have this problem: I want the stage leaderboard and the minute leaderboard In the top right of the screen. The problem is, when I put the minutes leaderboard in Serverscript service, I only have the stage leaderboard who is showing but not the minutes leaderboard and the leaderboard dont update, there a video the to understand my problem: https://streamable.com/jux3pk and theres the two scripts: -the stage leaderboard:

01local checkpoints = workspace:WaitForChild("Checkpoints droite")
02local remoteEvent = game.ReplicatedStorage:WaitForChild("ResetStatEvent")
03 
04game.Players.PlayerAdded:Connect(function(player)
05    local leaderstats = Instance.new("Folder")
06    leaderstats.Name = "leaderstats"
07    leaderstats.Parent = player
08 
09    local stage = Instance.new("IntValue")
10    stage.Name = "Stage"
11    stage.Value = 0
12    stage.Parent = leaderstats
13 
14    player.CharacterAdded:Connect(function(char)
15        local hum = char:WaitForChild("Humanoid")
View all 35 lines...

and the minutes leaderboard:

01local DataStoreService = game:GetService("DataStoreService")
02local DataStore = DataStoreService:GetDataStore("TimeStats")
03 
04game.Players.PlayerAdded:Connect(function(Player)
05    local Leaderstats = Instance.new("Folder")
06    Leaderstats.Name = "leaderstats"
07    Leaderstats.Parent = Player
08    local Minutes = Instance.new("IntValue")
09    Minutes.Name = "Minutes"
10    Minutes.Value = 0
11    Minutes.Parent = Leaderstats
12 
13    local Data = DataStore:GetAsync(Player.UserId)
14    if Data then
15        Minutes.Value = Data
View all 28 lines...

Thanks in advance!

2 answers

Log in to vote
1
Answered by
9mze 193
2 years ago
Edited 2 years ago
001local DataStoreService = game:GetService("DataStoreService")
002local MarketplaceService = game:GetService("MarketplaceService")
003local ReplicatedStorage = game:GetService("ReplicatedStorage")
004local Players = game:GetService("Players")
005 
006local checkpoints = workspace:WaitForChild("Checkpoints droite")
007local minutesDataStore = DataStoreService:GetDataStore("TimeStats")
008local remoteEvent = ReplicatedStorage:WaitForChild("ResetStatEvent")
009local stageDataStore = DataStoreService:GetDataStore("stageStore")
010 
011local function loop(callback, attempts, waitDuration, ...)
012    local _, success, result
013    for i = 1, attempts or 1 do
014        _, success, result = pcall(callback)
015        if success then
View all 124 lines...
0
Hi! Thanks a lot! I just have a small problem, I showed the wrong script for the leaderboard stage, here is the correct one: https://pastebin.com/8f4TB884 Thanks in advance! wDaerkfeX 37 — 2y
1
I've updated the script. It should handle both minutes and stage loading and saving. 9mze 193 — 2y
0
Hey! Thannks you for your answer, I have now an error in outpout: Stage is not a valid member of Folder "Players.wDaerkfeX.leaderstats" Thank you in advance! wDaerkfeX 37 — 2y
Ad
Log in to vote
1
Answered by 2 years ago

I think the problem is that you are making two separate leaderstats folders and Roblox is only using one of them.

I recommend putting it all in the same script like this:

01local checkpoints = workspace:WaitForChild("Checkpoints droite")
02local remoteEvent = game.ReplicatedStorage:WaitForChild("ResetStatEvent")
03local DataStoreService = game:GetService("DataStoreService")
04local DataStore = DataStoreService:GetDataStore("TimeStats")
05 
06game.Players.PlayerAdded:Connect(function(player)
07    local leaderstats = Instance.new("Folder")
08    leaderstats.Name = "leaderstats"
09    leaderstats.Parent = player
10 
11    local stage = Instance.new("IntValue")
12    stage.Name = "Stage"
13    stage.Value = 0
14    stage.Parent = leaderstats
15 
View all 59 lines...

I added some extra stuff in there to ensure no errors and to make the script for clean. Hope this helps!

0
Hey ty a lot for your answer, I have an error with the checkpoints, now they dont work, theres the output errors:Players.wDaerkfeX.PlayerGui.CharacterToStage:32: attempt to index nil with 'Position' and the other error is:Stage is not a valid member of Folder "Players.wDaerkfeX.leaderstats" line 7. Ty in advance for our help! have a nice day! wDaerkfeX 37 — 2y

Answer this question