#leaderstats aren't saving

15 messages · Page 1 of 1 (latest)

cosmic dawn
#

i already tried some debugging, but no luck

dusk widget
#

any errors?

cosmic dawn
dusk widget
#

id usually just check with a datastore plugin if it saves

#

do u have one

#

i tested your script. its workin fine

cosmic dawn
#

weird

#

but i managed to fix it tho

chilly mantle
#

yo check the enable studio acces to API services

#

oh sorry i didn't read the first sentence

#

so try ds:GetAsync("clicks_"..plr.UserId) or 0

#

because there says ds:GetAsync("gems_"..plr.UserId) or 0

dusk widget
cosmic dawn
#

it broke again.

i did only some changes, the script saves everything, but not the clicks for some reason

#
local ds = dsService:GetDataStore("PlayerData")
local RebirthEvent = game.ReplicatedStorage:WaitForChild("RebirthEvent")

game.Players.PlayerAdded:Connect(function(plr)
    local folder = Instance.new("Folder", plr)
    folder.Name = "leaderstats"

    local clicks = Instance.new("IntValue", folder)
    clicks.Name = "Clicks"
    clicks.Value = ds:GetAsync("clicks_"..plr.UserId) or 0
    clicks.Changed:Connect(function()
        ds:SetAsync("clicks_"..plr.UserId, clicks.Value)
        print(plr.Name.."'s Clicks saved to datastore: "..clicks.Value)
    end)


    local gems = Instance.new("IntValue", folder)
    gems.Name = "Gems"
    gems.Value = ds:GetAsync("gems_"..plr.UserId) or 0
    gems.Changed:Connect(function()
        ds:SetAsync("gems_"..plr.UserId, gems.Value)
        print(plr.Name.."'s Gems saved to datastore: "..gems.Value)
    end)

    local multiplier = Instance.new("IntValue", plr)
    multiplier.Name = "Multiplier"
    multiplier.Value = ds:GetAsync("multiplier_"..plr.UserId) or 0
    multiplier.Changed:Connect(function()
        ds:SetAsync("multiplier_"..plr.UserId, multiplier.Value)
        print(plr.Name.."'s Multiplier saved to datastore: "..multiplier.Value)
    end)

    local rebirths = Instance.new("IntValue", folder)
    rebirths.Name = "Rebirths"
    rebirths.Value = ds:GetAsync("rebirths_"..plr.UserId) or 0
    rebirths.Changed:Connect(function()
        ds:SetAsync("rebirths_"..plr.UserId, rebirths.Value)
        print(plr.Name.."'s Rebirths saved to datastore: "..rebirths.Value)
    end)
end)

RebirthEvent.OnServerEvent:Connect(function(Player)

    local leaderstats = Player:WaitForChild("leaderstats")
    local Multiplier = Player:WaitForChild("Multiplier")

    leaderstats.Clicks.Value = 0
    leaderstats.Rebirths.Value += 1

    Multiplier.Value += 2
end)```