Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use random functions?

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

✓ Accepted answer

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].

2 comments

0

so to define strength, I would put: local Strength = math.random(1,10) ?

0

Yes. Strength is just the name that you gave your variable.

This discussion is preserved as it was. New answers, comments, and votes are closed.