#rng system
1 messages · Page 1 of 1 (latest)
well if chance is a number
youre trying to loop thro a number
i assume you wanted to grab its value but not loop thro it
yes
yeah ik i fixed it later on
i done a bit of changing but now im only getting uncommons and commons
im not good at math
to be coding this
what are your attributes set to? also u should prob set roll variable inside the function not on global scope
every folder within rarities has a chance attribute set to it, common is 90, mythic is 0.01
and the rest is self explanatory
whats value of uncommon
40
yea thats your problem
roll is 0-100
and common is 90, uncommon 40
so thats 130!
you cant ever get higher ones
yikes..
fair enough, what do i do to fix it
as i said
im not good at math so i have no idea what to set the chances to
set the roll variable inside function, but first calculate total chances of all
i mostly used chatgpt and i regret doing that because i want to learn by myself; not by an ai bot
am i on the right path
almost, just make a variable that holds the sum of chances
just do something like
total = 0
for _, chance in rarities do
total += chance:GetAttribute("chance")
end
then roll from 0 to total
and then keep your previous code u had
ive basically done that i think
you dont
it really doesnt do anything
go back to this rng logic
BUT do the chance fix so u dont loop over number
and
before that code in same function
SUM all the chances
so another for loop
something like this
then roll
chance fix meaning the code you sent as an example?
the original error you had, where u tried to use loop in number
why don't u not use Random.new()?
completely forgot about that, ive never used it aswell
try it
you dont rly need to
almost but
youre using same variable for 2 things
\
use something like total or totalchancefor the first loop and inside math.random
or just reset the variable back to 0 after roll and before loop
so i lowkey didnt know what you meant but i asked gpt and he basically returned the same code, but changed the currentchance in the first loop to something different
i didnt change it because i had no idea what to change it to and i didnt think it really mattered if i did
and it worked aswell
you just used same variable for 2 diffrent counters
i know its what i just said
it would bug out if you used same for SUM and then never reset it to 0 and use to to check what you rolled
glad it works
yeah ive realised that now
thank you for the help
print,print and once again print
for like remembering and like starting thinking logically more
i used to do that
but i just stopped
also wkizi should i feel grief because im using chatgpt instead of learning by myself
@violet lily the more you code the more you get better