My entire leaderboard works, with saving, but when I get to this:

-- Note: 0 = true, 1 = false

DataStore = game:GetService("DataStoreService"):GetDataStore("OwnsTest")
local t = script.Parent.Frame.Owns
local p = t.Parent.Parent.Parent.Parent.Parent.Parent
local b = script.Parent.Frame.TextButton

b.MouseButton1Click:connect(function()
	local st = p.AnimsChar.OwnsTest
	if st.Value == 1 then
		st.Value = 0
	elseif st.Value == 0 then
		t.Text = "True"
	end
end)

game.Players.PlayerAdded:connect(function(plr)	
	local owns = 1
	local save = "plr-"..plr.userId
	local savedVals = DataStore:GetAsync(save)
	if savedVals then
		owns = savedVals
	else
		owns = 1
		DataStore:SetAsync(save, owns)
	end
end)

game.Players.PlayerRemoving:connect(function(plr)
	local owns = plr.AnimsChar.OwnsTest.Value
	local save = "plr-"..plr.userId
	DataStore:SetAsync(save, owns)
end)

It suddenly doesn't work

This is my leaderboard:

DataStore = game:GetService("DataStoreService"):GetDataStore("Values")

game.Players.PlayerAdded:connect(function(plr)
    local val = 0
    local save = "plr-"..plr.userId
    local savedVals = DataStore:GetAsync(save)
    if savedVals then
        val = savedVals
    else 
        val = 0
        DataStore:SetAsync(save,val)
    end

    local stat = Instance.new("IntValue", plr)
    stat.Name = "leaderstats"   

    local cred = Instance.new("IntValue", stat)
    cred.Value = val
    cred.Name = "Coins"

	local folder = Instance.new("Folder", plr)
	folder.Name = "AnimsChar"
	
	-- BoolVals--
	local st = Instance.new("IntValue", folder)
	st.Name = "OwnsTest"
	st.Value = 1
end)

game.Players.PlayerRemoving:connect(function(plr)
    local val = plr.leaderstats.Coins.Value
    local save = "plr-"..plr.userId
    DataStore:SetAsync(save,val)
end)

1 comment

0

Accidentally moderated this, sorry. thought it would report it to staff to fix.