How would i implement a luck system with this chance system?

Hey! My apologies if posts similar to this are already made within the past, but i am wondering on how i would implement a luck system with my current spin/chance system? I have a luck multiplier, like 1x-5x, and i want to implement it so that the higher the multiplier, the higher chance you have on getting something good. Here is my current script, take a look:

Spin Function

function SpinHandler:Spin()
	
	local R = Random.new()

	local MAX_RANGE = 100
	local MIN_RANGE = 0
	local percentages = SpinHandler.Percentages
	local getRandomItem = R:NextNumber(MIN_RANGE, MAX_RANGE)
	local found
	for item, bounds in pairs(percentages) do
		if getRandomItem >= bounds[1] and getRandomItem < bounds[2] then
			found = item
			break
		end
	end

	return found
end

How my chances, and percentages are set up:

local SpinHandler = {
	
	--// This is the handler for spinning and stuff
	
	UGCItems = {
		
		[1] = {AssetID = 17226923871, Image = 0, Name = "Red Valkyrie Helm Of Desperationis", Chance = ".1%"}	
		
	},
	
	Items = {
		
		[1] = {Image = 17276326040, Chance = "10%", Color = Color3.fromRGB(255, 255, 127), Text = "1+ Spin"},
		[2] = {Image = 17276326218, Chance = "5%", Color = Color3.fromRGB(255, 255, 127), Text = "3+ Spins"},
		[3] = {Image = 17276325900, Chance = "5%", Color = Color3.fromRGB(255, 255, 127), Text = "5+ Spins"},
		[4] = {Image = 0, Chance = ".1%", Color = Color3.fromRGB(85, 0, 255), Text = "UGC"},
		[5] = {Image = 16193577063, Chance = "80%", Color = Color3.fromRGB(0, 170, 127), Text = "Nothing"}
	},
	
	ItemsInfo = {

		["1+ Spin"] = {Image = 17276326040, Chance = "10%", Color = Color3.fromRGB(255, 255, 127), Text = "1+ Spin"},
		["3+ Spins"] = {Image = 17276326218, Chance = "5%", Color = Color3.fromRGB(255, 255, 127), Text = "3+ Spins"},
		["5+ Spins"] = {Image = 17276326218, Chance = "5%", Color = Color3.fromRGB(255, 255, 127), Text = "5+ Spins"},
		["UGC"] = {Image = 0, Chance = ".1%", Color = Color3.fromRGB(85, 0, 255), Text = "UGC"},
		["Nothing"] = {Image = 16193577063, Chance = "80%", Color = Color3.fromRGB(0, 170, 127), Text = "Nothing"}
	},
	
	
	
	Percentages = {
		["Nothing"] = {20, 100}, --// fair %, yeah?
		["UGC"] = {0, .005}, --// 
		["1+ Spin"] = {10, 20}, --// 10%
		["3+ Spins"] = {5, 10}, --// 5%
		["5+ Spins"] = {.1, 5}}} --// 5%

I use this

Well, this system wouldn’t really help me. I know how to make a chance system, i just don’t know how to implement the luck multiplier :confused:

I think it comes down to how you want the luck system to work, since there are many options:

A: Luck multiplier adds more spin tries and picks the best result.

function SpinHandler:Spin(Luck: number)
	
	local R = Random.new()

	local MAX_RANGE = 100
	local MIN_RANGE = 0
	local percentages = SpinHandler.Percentages
	local getRandomItem = MAX_RANGE
	-- Assuming lower number means better items
	for i=1, Luck do
		getRandomItem = math.min(R:NextNumber(MIN_RANGE, MAX_RANGE), getRandomItem)
	end
	local found
	for item, bounds in pairs(percentages) do
		if getRandomItem >= bounds[1] and getRandomItem < bounds[2] then
			found = item
			break
		end
	end

	return found
end

B: Luck multiplier lowers MAX_RANGE

function SpinHandler:Spin(Luck: number)
	
	local R = Random.new()

	local MAX_RANGE = 100 / Luck -- Again assuming smaller numbers mean better items
	local MIN_RANGE = 0
	local percentages = SpinHandler.Percentages
	local getRandomItem = R:NextNumber(MIN_RANGE, MAX_RANGE)
	local found
	for item, bounds in pairs(percentages) do
		if getRandomItem >= bounds[1] and getRandomItem < bounds[2] then
			found = item
			break
		end
	end

	return found
end

C: Dynamically calculate what the new %s look like and use those for selecting item.

Hope one of these you find helpful! :smiley:

If this was like a D&D game luck would just add directly to the percentage chance of the roll.