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

I’m trying to make it where the leaderboard shows as Breaths But it wont work?

Asked by 3 years ago
Edited 3 years ago
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)
0
which video bigkiddo27 6 — 3y
0
Habe you noticed that, template.breaths.Text = breaths should be template.breaths.Text = "breaths" MrCatDoggo 213 — 3y
0
He's setting the breaths text to breaths which is variable he set. mixgingengerina10 223 — 3y
View all comments (4 more)
0
Are there any errors @RareBlue? mixgingengerina10 223 — 3y
0
no Configuator 158 — 3y
0
OH GOD NOT A CORONA VIRUS SIMULATOR Ultim8creeper 15 — 3y
0
its not lmaooo Configuator 158 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

)

Ad

Answer this question