You could make a simple frequency table like so.
local numbers = {10, 10, 12, 12, 15, 10}
function Count(num)
for _, num in pairs(num) do
if script:FindFirstChild(num) then
script[num].Value = script[num].Value + 1
else
local new = Instance.new('IntValue', script).Name = num
new.Value = 1
end
end
local results = {}
for _, num in pairs(count) do
results[tostring(num)] = script[num].Value
end
return results
end
print(Count(numbers)[10])
This would print "Ten : 3, Twelve : 2".
Also, math.random needs rather 0 parameters or 2, not 1. You can do
local anum = math.random()
print(anum)
and that would print decimal numbers from 0 to 1, or have numbers between two numbers like
local anum = math.random(1, 10)
print(anum)
This would not print decimals, however print a number from 1 to 10. Also, use math.randomseed. It randomizes your math.random statements. To make the most random numbers that is NOT predictable what will happen even if you know what time it is, nor using math.random, I do
math.randomseed(tick() / wait() * wait() % wait() ^ wait() - wait() + wait())
If you dont know already, wait() returns a number how long it actually waited. Sometimes they have to hold off the task because something else is running and they cannot handle running another task at the moment. Even in a plain baseplate game, this will always be different. All those operators do not have to be in order, they are just there to make it random.
Also, math.randomseed needs to be before you do math.random like
math.randomseed(tick() / wait() * wait() % wait() ^ wait() - wait() + wait())
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
print(math.random(1, 10)
Hope this helps!
4 comments
Thanks, this sort of helps, but I there are going to be thousands of different values, is there a way to do it for thousands of values, or is that impossible?
Try my soultion.
I know it works, but I'm wondering how it would work for like thousands of numbers, would i have to post all of them in the table myself? or is there another way? thousands of different combinations I mean
There.