Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script doesn't show the leaderboard?

Help if you can!

local ds = game:GetService("DataStoreService")
local statsStore = ds:GetGlobalDataStore("PlayerStats")

function getPlayerData(player)
	local victory, info = false, nil
	repeat
		victory = pcall(function()
			info = statsStore:GetAsync("Data"..player.UserId)
		end)
		
		wait(2)
	until victory
	
	player.DataLoaded.Value = true
	return info
end

function savePlayerData(player)
	if player.DataLoaded.Value then
		pcall(function()
			statsStore:SetAsync("Data"..player.UserId, player.leaderstats.Lifts.Value)
		end)
	end
end

function giveStats(player)
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	local lifts = Instance.new("IntValue")
	lifts.Name = "Lifts"
	local loaded = Instance.new("BoolValue", player)
	loaded.Name = "DataLoaded"
	
	local data = getPlayerData(player)
	if data == nil then
		data = 0
	end
	lifts.Value = data
end

game.Players.PlayerAdded:Connect(giveStats)
game.Players.PlayerRemoving:Connect(savePlayerData)

while wait(15) do
	for _, player in pairs(game.Players:GetChildren()) do
		savePlayerData(player)
	end
end

1 answer

✓ Accepted answer

Line 29, IntValue is parented to nil. Try

lifts.Parent = leaderstats

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.