local ds = game:GetService("DataStoreService") local coinsODS = ds:GetOrderedDataStore("BreathsStats") local timeUntilReset = 10 while wait(1) do timeUntilReset = timeUntilReset - 1 script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..." if timeUntilReset == 0 then timeUntilReset = 10 for i, plr in pairs(game.Players:GetPlayers()) do coinsODS:SetAsync(plr.UserId, plr.leaderstats.Breaths.Value) end for i, leaderboardRank in pairs(script.Parent:GetChildren()) do if leaderboardRank.ClassName == "Frame" then leaderboardRank:Destroy() end end local success, errorMsg = pcall(function() local data = coinsODS:GetSortedAsync(false, 50) local coinsPage = data:GetCurrentPage() for rankInLB, dataStored in ipairs(coinsPage) do local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key)) local breaths = dataStored.value local template = script.Template:Clone() template.Name = name .. "Leaderboard" template.PlrName.Text = name template.Rank.Text = "#" .. rankInLB template.breaths.Text = breaths template.Parent = script.Parent end end) end end
I got this script from youtube and I’m trying to make it where the leaderboard shows as Breaths but when I tried to change it, it wouldn't work? can someone help?
here is my datatstore script
local Data = game:GetService("DataStoreService"):GetOrderedDataStore("BreathsStats") game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local Breaths = Instance.new("IntValue", folder) Breaths.Name = "Breaths" Breaths.Value = 0 local dataLoad = Data:GetAsync(tostring(plr.UserId)) if dataLoad then Breaths.Value = dataLoad end end) game.Players.PlayerRemoving:Connect(function(plr) Data:SetAsync(tostring(plr.UserId), plr.leaderstats.Breaths.Value ) end)
In the first script you have:
local coinsODS = ds:GetOrderedDataStore("BreathsStats")
In the second script you have:
local Data = game:GetService("DataStoreService"):GetDataStore("BreathsStats")
To fix that just replace the first line of the second script to
local Data = game:GetService("DataStoreService"):GetOrderedDataStore("BreathsStats")
(also with your other errors, replace line 14 on the second script with this:
Breaths.Value = dataLoad
)