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

I’m trying to make it where the leaderboard shows as Breaths But it wont work?

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("BreathsStats")


local timeUntilReset = 10


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 10
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Breaths.Value)
		end
		
		for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
			
			if leaderboardRank.ClassName == "Frame" then
				leaderboardRank:Destroy()
			end
		end
		
		
		local success, errorMsg = pcall(function()
			
			local data = coinsODS:GetSortedAsync(false, 50)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local breaths = dataStored.value
				
				
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = name
				
				template.Rank.Text = "#" .. rankInLB
				
				template.breaths.Text = breaths
				
				template.Parent = script.Parent				
			end			
		end)
	end
end

I got this script from youtube and I’m trying to make it where the leaderboard shows as Breaths but when I tried to change it, it wouldn't work? can someone help?

here is my datatstore script

local Data = game:GetService("DataStoreService"):GetOrderedDataStore("BreathsStats")

game.Players.PlayerAdded:Connect(function(plr)
	local folder = Instance.new("Folder", plr)
	folder.Name = "leaderstats"
	
	local Breaths = Instance.new("IntValue", folder)
	Breaths.Name = "Breaths"
	Breaths.Value = 0
	
	local dataLoad = Data:GetAsync(tostring(plr.UserId))
	
	if dataLoad then
		Breaths.Value = dataLoad
	end
end)
game.Players.PlayerRemoving:Connect(function(plr)
	Data:SetAsync(tostring(plr.UserId),
		plr.leaderstats.Breaths.Value
	)
end)

8 comments

0

which video

0

Habe you noticed that, template.breaths.Text = breaths should be template.breaths.Text = "breaths"

0

He's setting the breaths text to breaths which is variable he set.

0

Are there any errors @RareBlue?

0

no

0

OH GOD NOT A CORONA VIRUS SIMULATOR

0

its not lmaooo

1 answer

In the first script you have:

local coinsODS = ds:GetOrderedDataStore("BreathsStats")

In the second script you have:

local Data = game:GetService("DataStoreService"):GetDataStore("BreathsStats")

To fix that just replace the first line of the second script to

local Data = game:GetService("DataStoreService"):GetOrderedDataStore("BreathsStats")

(also with your other errors, replace line 14 on the second script with this:

Breaths.Value = dataLoad

)

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