Custom RNG Kit, random values

Okay so basically I an trying to make a sol’s RNG kit and I’ve been pretty successful although I have one ongoing issue which somehow no one out of the hundreds of users have seen/realised.

local module = {
	{Name = "Rare", OneIn = 1000, TextColor = Color3.new(0.4, 0.5, 1)},
	{Name = "Bruh", OneIn = 3, TextColor = Color3.new(1, 0.741176, 0.529412)},
	{Name = "Dark Knight", Cutscene = 1, OneIn = 10000, TextColor = Color3.new(0.34902, 0.34902, 0.34902), AuraFont = Enum.Font.Cartoon},
}

return module

As you can see, I’m 90% sure it’ll be impossible to calculate these chances and if one is 1 in 3 that should mean a 0.3333 chance to get it, so 1 in 3 rolls although that would need a counter balance, weather that’s spread over a few auras or just one so for example we could add 2 more that are also 1 and 3 and it would work but if we add one that’s 1 in 2 then it wouldn’t work as the total of 1 / (1 / the values added together doesn’t) ~= 1 which I’m pretty sure it should be. Maybe I’ve got the maths wrong but I want this to be easy to understand for new scripts and people that don’t know maths to add new chances and auras.

Question:
Is there any good options to fix this issue or any other ideas on how to calculate the chances. Or maybe another approach to the situation.

4 Likes

maybe a weighted luck system would help you?

6 Likes

It would be good although sadly my viewers want to set the chances to “OneIn = 10” (would be 1 in 10 and 10%) but I don’t think there is a possible way to do it unless they know they would have to balance it with something equal to 90%

1 Like

So I threw together a quick rng script if you have questions about it feel free to ask

local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("Roll")

local chances = { --Better rolls or higher chance rolls should be below the worse one
	{"Common", 1}, --{The name is "Common", 1 in 1 chance of getting it}
	{"Good", 3}, --{The name is "Good", 1 in 3 chance of getting it}
	{"Uncommon", 5}, --{The name is "Uncommon", 1 in 5 chance of getting it}
	{"Rare", 10} --{The name is "Rare", 1 in 10 chance of getting it}
}

local function getRoll()
	local bestRoll
	for i = 1, #chances do
		local ran = math.random(1, chances[i][2])
		if ran == 1 then
			bestRoll = i
		end
	end
	return bestRoll
end

remote.OnServerEvent:Connect(function()
	local roll = getRoll()
	print(chances[roll][1].." 1 out of "..chances[roll][2])
end)

This should fix your issue because now there is a guarantied roll no matter what.

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.