How can I make that the bigger the number, the less the chance will be?

Hello, so I’m making a difficulty system. The farther away the npc’s difficulty, the less of a chance of it spawning in. BUT if a difficulty is less than the number, the chance will be higher than the number closer. While I want that to be the opposite. This is my script, if you have any questions then feel free to say below

local function GetChance(Hardness, OriginDifficulty, Monster)
	local Chance = 0
	
	
	local Distance =  (OriginDifficulty - Hardness) 
	Chance = Distance / 2 * 0.5 
	if Distance == 1 then
		Chance = Chance * 2 * 2
	end

	if Distance == 0 then
		Chance =  10
		
	elseif Distance < 0 then

		Distance = (Hardness - OriginDifficulty) / 2 * 0.5 / 2
		Chance = Distance
	
	end


	return Chance

end

Any help is appreciated!!!

return MaxChance-Chance.

2 Likes

You could also try 1 / x, since you don’t need a MaxChance value to use it

1 Like

whats 1 / x? What’s X???

how do I get the “MaxChance”? ? ? ? ? ?

1 Like

x is just a placeholder value. Just put the number you want to convert into the part where x is.

1 Like

So using what @NyrionDev and @Inconcludable said, I was able to get bigger numbers, but the number with the farther distance still gets the most chance, new script:

local function GetChance(Hardness, OriginDifficulty, Monster)
	local MaxChance = 10
	local Chance = 0
	
	
	local Distance =  (OriginDifficulty - Hardness) 

	Chance = Distance / 2 
	if Distance == 1 then
		Chance = Chance * 2 * 2 
	end

	if Distance == 0 then
		Chance =  10
		
	elseif Distance < 0 then

		Distance = (Hardness - OriginDifficulty) / 2 * 0.5 / 2
		Chance = Distance
	


end
	return MaxChance-Chance

Any help is appreciated! Thanks for the help guys!

Fixed it doing this:

local function GetChance(Hardness, OriginDifficulty, Monster)
	local MaxChance = 10
	local Chance = 0
	
	
	local Distance =  (OriginDifficulty - Hardness)
	local CalDistance = Distance / Distance * (Distance / 2)
	print(CalDistance)
	Chance = CalDistance
	if Distance == 1 then
		Chance = Chance * 2 * 2 
	end

	if Distance == 0 or CalDistance == 0 then
		Chance =  10
		
	elseif Distance < 0 then

		Distance = (Hardness - OriginDifficulty) / 2 
		Chance = Distance
	


end
	return MaxChance-Chance

end

Also rip my 69 solutions :frowning:

1 Like