math.random(plr.leaderstats.amethyst.Value = 0,plr.leaderstats.amethyst.Value = 1)
What can I fix in this line of code? It brings a lot of errors and I just want to fix it.
math.random(plr.leaderstats.amethyst.Value = 0,plr.leaderstats.amethyst.Value = 1)
What can I fix in this line of code? It brings a lot of errors and I just want to fix it.
What exactly are you trying to do? Math.random takes two numbers but currently you’re defining the amethyst value inside the math.random function.
Just do this:
math.random(0, plr.leaderstats.amethyst.Value)
However in your original code you’re just giving a range of the same number since the value amethyst is static and not changing when the function is called.
I’m trying to make it so that there is a chance that you would not get an amethyst (yes, I fixed that with the + before the equals) and a chance you would get an amethyst.
The variable “randNumber” will be defined as an integer from 1-2. If “randNumber” is 1 then the value is incremented, if it’s 2 then nothing happens.
local randNumber = math.random(1, 2)
if randNumber == 1 then
plr.leaderstats.amethyst.Value += 1
end
plr.leaderstats.amethyst.Value += math.random(0, 1)
I assume this is the behavior you’re attempting to achieve (randomly adding either 0 or 1 to the player’s amethyst stat).
You can even add multiple amethysts by multiplying the potential zero or one.
plr.leaderstats.amethyst.Value += math.random(0, 1) * INCREMENT