I tried all that I know. I know what math.random is but I do not know how to make it go to a variable. Here is my attempt
while true do
wait(.1)
MyNum = math.random
if MyNum == 1 then
I tried all that I know. I know what math.random is but I do not know how to make it go to a variable. Here is my attempt
while true do
wait(.1)
MyNum = math.random
if MyNum == 1 then
Well first of all the number range for
math.random
is -infinity to infinity so the chances of you getting 1 in that large amount of numbers are slim to none so what you could do is
while wait(3) do -- every 3 seconds
local Var = math.random(-5,5) --setting range to be -5 through 5
if Var == 1 then -- which is 1/11 chances of getting a 1 but you get the point
print("Var = "..Var)
else
print("No")
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
what do you mean... local MyNum = math.random(1,100) if MyNum == 30 then --code end MyNum is the random variable, to simply transfer it say, local NewMyNum = MyNum, I really do not understand what you are thinking right now.
Thank you, I am just barely starting out with scripting. Sorry if i sound like an idiot.
Tip for writing questions on here, it's recommended to put code in the 'Code Block' (The <> at the top of the screen when editing the question) format, it makes it easier to traverse the code. Also good luck on programming.
Tip for writing questions on here, it's recommended to put code in the 'Code Block' (The <> at the top of the screen when editing the question) format, it makes it easier to traverse the code. Also good luck on programming.