Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use random functions?

Asked by 10 years ago

More specifically, how can I generate a random number between 1 and 10 and then define the number as a string? For example

local Strength = (random number generated)

1 answer

Log in to vote
0
Answered by 10 years ago

To generate a random number, use math.random(1,10)

Also, any value (integer, Boolean. string) can be made into a string. Say the string variable is as follows: local string = "The number we generated is " .. Strength .. "."

This is called concatenation. The two periods (dots) in between string segments are the concatenation operators. They output any value given and/or add it to the variable it's placed in. This string variable will be displayed as:

The number we generated is [number generated with the "math.random" function].

0
so to define strength, I would put: local Strength = math.random(1,10) ? Shaydesilva 85 — 10y
0
Yes. Strength is just the name that you gave your variable. ModZombie 70 — 10y
Ad

Answer this question