How can I get a random number between 1 and 10, and add it to a string. for example
I get 7
'You caught a 7lb fish!'
another example:
You caught a 2lb fish!'
please help
How can I get a random number between 1 and 10, and add it to a string. for example
I get 7
'You caught a 7lb fish!'
another example:
You caught a 2lb fish!'
please help
Use math.random.
lbs=math.random(1,10)
And this was downvoted because.... 0_o
Neutralized, some people just find it funny to down-vote members with ^rep
Probably downvoted because of lack of information. If your answer isn't well written and just looks generally sloppy, that's enough of a reason to downvote over a better presented answer.
Yeah, but you got to admit, this is old content. I didn't give much explanation with my scripts when I was starting out and I ended up getting my butt kicked when harder questions started coming out. So I of course had to give better explanation with my scripts.
A way to do this is using
local g = math.random(1,10)
this creates a random number between one, and ten.
To put this into a string, you would do string value.
local stringvalue = script.Parent.Pounds.Value -- Referencing the value.
local f = tostring("You have caught a"..g.."lb. fish!") -- This combines g, our math.random, and the string.
stringvalue = f -- Makes the value equal to the tostring function.
Hope this helps!
lbs = math.random(0, 10)
if lbs > 5 then
print("You got a big fish ! :)")
else
print("You got a little fish ! :(")
end
or you can also do this:
lbs = math.random(0, 10)
print("You caught a "..lbs.."lb".."fish !")
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I'll get to work on an answer.