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

I have a datastore which count the deaths but it stopped working. Can someone help?

Asked by 4 years ago
Edited 4 years ago

So I have three different leader stats folders in the player service: one for counting a players deaths, time spent in-game and their stage in the lobby but when I run my game it says that all three leader stats folders are not a member of the player. When I look at my player service in my character while in-game, there are three leader stats folders.

Deaths script:

01local plrs = game.Players
02local DataStoreService = game:GetService("DataStoreService")
03local DataStore = DataStoreService:GetDataStore("Deaths") -- Change this with a different name.
04 
05print ("Deaths leaderstats working")
06 
07plrs.PlayerAdded:Connect(function(plr)
08 
09    local jats = Instance.new("Folder")
10    jats.Name = "leaderstats"
11    jats.Parent = plr
12 
13    local wipeouts = Instance.new("IntValue")  
14    wipeouts.Name = "Deaths"
15    wipeouts.Value = 0
View all 36 lines...

Time spent script =

01local plrs = game.Players
02local DataStoreService = game:GetService("DataStoreService")
03local DataStore = DataStoreService:GetDataStore("Seconds") -- Change this with a different name.   
04 
05print ("Time leaderstats working")
06 
07plrs.PlayerAdded:Connect(function(plr)
08 
09    local jats =Instance.new("Folder"
10    jats.Name = "leaderstats"
11    jats.Parent = plr
12 
13    local wipeouts = Instance.new("IntValue")  
14    wipeouts.Name = "Seconds"
15    wipeouts.Value = 0
View all 33 lines...

Stage script:

01local dss = game:GetService("DataStoreService")
02local obbyDS = dss:GetDataStore("ObbyData")
03 
04local checkpoints = workspace.Checkpoints
05print("Checkpoint leaderstats working")
06 
07 
08game.Players.PlayerAdded:Connect(function(plr)
09 
10    local obbyData = obbyDS:GetAsync(plr.UserId .. "-obbyStageProgress")
11 
12    local ls = Instance.new("Folder")
13    ls.Name = "leaderstats"
14    ls.Parent = plr
15 
View all 65 lines...

This only started happening after I implemented a leaderboard for whoever has played the longest:

01local DataStoreService = game:GetService("DataStoreService")
02local WinsLeaderboard = DataStoreService:GetOrderedDataStore("WinsLeaderBoard")
03 
04local function updateLeaderboard()
05        local success, errorMessage = pcall (function()
06                local Data =WinsLeaderboard:GetSortedAsync(false, 5)
07                local WinsPage = Data:GetCurrentPage()
08                for Rank, data in ipairs(WinsPage) do
09                       local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
10                       local Name = userName
11                       local Seconds = data.value
12                       local isOnLeaderboard = false
13                       for i, v in pairs(game.Workspace.Leaderboardarea.Leaderboard.LeaderboardGUI.Holder:GetChildren()) do
14                             if v.Name2.Text == Name then
15                                  isOnLeaderboard = true
View all 53 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

One thing I found was that in the Deaths script, at line 22, you reference the Deaths object as Death. This might have something to do with it. Also, why do you have 3 different leader stats folders? I think that is an issue. seeing as there are three, your referencing in the Leaderboard script at Line 40 might be an issue. Try changing the three scripts so that they all use a single leader stats folder

0
thanks for the answer TheDragonSlayer5481 -11 — 4y
Ad

Answer this question