Datastores not showing on da leaderboard?!1!

Self explinatory, scritp that should do datastores, datastores not loading ):

image

local KillsDatastore = game:GetService("DataStoreService"):GetDataStore("KillsDatastore")

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "Leaderstats"
	local Kills = Instance.new("NumberValue", leaderstats)
	Kills.Name = "Kills"
	Kills.Value = 0
	local TotalKills = Instance.new("NumberValue", leaderstats)
	TotalKills.Name= "Total Kills"
	TotalKills.Value = 0
	local CurrentCharacter = Instance.new("StringValue", plr)
	CurrentCharacter.Name = "CurrentCharacter"
	CurrentCharacter.Value = "Character1"
	
	local success, errormessage = pcall(function()
		local Key = plr.UserId
		local Data = KillsDatastore:GetAsync(Key)
		
		if Data then
			TotalKills.Value = Data[1]
		end
	end)
	
	while not success do
		task.wait(3)
		local Key = plr.UserId
		local Data = KillsDatastore:GetAsync(Key)
		
		if Data then
			TotalKills.Value = Data[1]
		end
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local success, errormessage = pcall(function()
		local Key = plr.UserId
		local DataTable = {}
		
		table.insert(DataTable, plr.leaderstats["Total Kills"].Value)
		
		KillsDatastore:SetAsync(Key, DataTable)
	end)
	
	while not success do
		task.wait(3)
		
		local Key = plr.UserId
		local DataTable = {}

		table.insert(DataTable, plr.leaderstats["Total Kills"].Value)

		KillsDatastore:SetAsync(Key, DataTable)
		
	end
end)
1 Like

Rename the leaderstats folder to “leaderstats”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.