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

how to set maxvalue leaderstats to 1 billion?

I'm trying to limit but it looks like the leaderstats with the name of rebirths is limiting at 10

https://prnt.sc/122ji7i

local PlayerStatsDS = game:GetService("DataStoreService"):GetDataStore("Player_StatsOL2")

game.Players.PlayerAdded:Connect(function(NP)
	
	local Key = "PDS-".. NP.UserId
	
	local GetSave = PlayerStatsDS:GetAsync(Key)
	
	local PSF = Instance.new("Folder", NP)
	PSF.Name = "leaderstats"
	
	local StatsFolder = script.Stats
	
	for _, S in pairs(StatsFolder:GetChildren()) do
		local NS = Instance.new(S.ClassName, PSF)
		NS.Name = S.Name
		NS.Value = S.Value
	end
	
	local timeplayed = PSF:WaitForChild("Time Played")
	
	spawn(function()
		while true do
			wait(1)
			timeplayed.Value = timeplayed.Value + 1
		end
	end)
	
	if GetSave then
		for n, Stat in pairs(PSF:GetChildren()) do
			Stat.Value = GetSave[n]
		end
	else
		local STS = {}
		for _, Stat in pairs(StatsFolder:GetChildren()) do
			table.insert(STS, Stat.Value)
		end
		PlayerStatsDS:SetAsync(Key, STS)
	end
end)

game.Players.PlayerRemoving:connect(function(OP)
	
	local Key = "PDS-".. OP.UserId
	
	local StatsFolder = OP.leaderstats
	
	local STS = {}
	for _, Stat in pairs(StatsFolder:GetChildren()) do
		table.insert(STS, Stat.Value)
	end
	PlayerStatsDS:SetAsync(Key, STS)
end)

1 comment

0

What type of value are you instancing to the leaderstats folder?

1 answer

Use a DoubleConstrainedValue as the class for the stat you will be instancing into the leaderstats folder. With this value, you can change the MinValue and the MaxValue of the stat.

For example:

local value = Instance.new("DoubleConstrainedValue",PSF)
value.Name = "" -- Put name here
value.MinValue = 1 -- Min Value (1)
value.MaxValue = 1000000000 -- Max Value (1 Billion)

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