How to fix Chance system to go lower numbers than 0,1

  1. What do you want to achieve?
    I am recently trying to make Chance System with very rare numbers.

  2. What is the issue?
    Like the topic name says “Chances” wont go lower than 0,1.

  3. What solutions have you tried so far?
    I read a few posts here on Devforum but I am not really experienced in these type of things so thats why I am making separate post for this.

Script inside ServerScriptServices:

local M = require(game.ReplicatedStorage.ModuleScript)

function RNG()
	local nmg = 0
	for rn, Chance in pairs(M) do
		nmg += Chance
	end
	local RandomNum = math.random(nmg)
	for rn, Chance in pairs(M) do
		if RandomNum <= Chance then
			return rn
		else
			RandomNum -= Chance
		end
	end
end
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		while wait() do
			print(RNG())
		end
	end)
end)

Module Script inside Replicated Storage

return {
	["A"] = 99.899,
	["B"] = 0.1,
	["C"] = 0.001,
}

Thanks so much for help! :slight_smile:

Try changing the module to

	["A"] = 99899,
	["B"] = 100,
	["C"] = 1,
}

Normally loops like plain integers

1 Like

Okay I’ll give it a try and let you know. Thank you.

Sorry for few days delay its working thank you so much!