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

leaderboard stats don't show, how do i fix this?

Asked by 4 years ago

basically i am trying to make stats that save, but one of the stats don't save and i tried fixing it now the stats don't display at all. how do i fix this?

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("BrickCountSaveSystem")
local ds2 = datastore:GetDataStore("DeathSaveSystem")


game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local deathcount = Instance.new("IntValue", folder)
deathcount.Name = "Deaths"
local BrickCount = Instance.new("IntValue", folder)
BrickCount.Name = "Bricks"

BrickCount.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, BrickCount.Value)

BrickCount.Changed:connect(function()
    ds1:SetAsync(plr.UserId, BrickCount.Value)

deathcount.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsync(plr.UserId, deathcount.Value)

deathcount.Changed:connect(function()
    ds2:SetAsync(plr.UserId, deathcount.Value)
end)
    end)

game:GetService("Players").PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
        player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1

end)
    end)
        end)    


0
This isn't an answer, but for better performance, you shouldn't use the parent parameter in Instance.new Kataclysmix 23 — 4y
0
i agree recanman 88 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

it is not the code that is wrong, go to you game home --> game settings --> options --> allow http requests and enable studio acess to api services

Ad
Log in to vote
0
Answered by 4 years ago

ok nvm i messed around w/ the code and fixed every problem i've had with it

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("DeathSaveSystem")
local ds2 = datastore:GetDataStore("BrickSaveSystem")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local bricks = Instance.new("IntValue")
    bricks.Name = "Bricks"
    bricks.Parent = leaderstats

    local deaths = Instance.new("IntValue")
    deaths.Name = "Deaths"
    deaths.Parent = leaderstats

    player.CharacterAdded:Connect(function(char)
        local humanoid = char:FindFirstChild("Humanoid")
        humanoid.Died:Connect(function()
            deaths.Value = deaths.Value + 1
        end)
    end)

    bricks.Value = ds2:GetAsync(player.UserId) or 0
    ds2:SetAsync(player.UserId, bricks.Value)

    deaths.Value = ds1:GetAsync(player.UserId) or 0
    ds1:SetAsync(player.UserId, deaths.Value)

    bricks.Changed:connect(function()
        ds2:SetAsync(player.UserId, bricks.Value)
    end)

    deaths.Changed:connect(function()
        ds1:SetAsync(player.UserId, deaths.Value)
    end)
end)
0
oh, then accept your answer ivan6361 34 — 4y
0
how do i do that greendayshade 5 — 4y

Answer this question