So, I know math random selects a random number. But can you set it to select a number within a range you assign? Something like
math random 10 - 20
Sorry about my LUA, I'm still learning! Just need this question answered, because i'm confused.
So, I know math random selects a random number. But can you set it to select a number within a range you assign? Something like
math random 10 - 20
Sorry about my LUA, I'm still learning! Just need this question answered, because i'm confused.
math.random(10,20)
gets a random number from 10 - 20 as you said.
Remember to use . and ()
if this doesn't work then open the output and type this in:
print(math.random(10,20))
Example
Baseplate = game.Workspace.BasePlate
while true do
wait(1)
ColorstoChooseFrom = math.random(1,3)
if ColorstoChooseFrom == 1 then
Baseplate.BrickColor = BrickColor.new("Red")
end
if ColorstoChooseFrom == 2 then
Baseplate.BrickColor = BrickColor.new("Blue")
end
if ColorstoChooseFrom == 3 then
Baseplate.BrickColor = BrickColor.new("Green")
end
end
Thats An Exapmple on How Math.Random Works
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
https://www.youtube.com/watch?v=KEuMtmtpnqk