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

Help with randomising?

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

1 comment

0

I'll get to work on an answer.

3 answers

Use math.random.

lbs=math.random(1,10)

4 comments

0

And this was downvoted because.... 0_o

0

Neutralized, some people just find it funny to down-vote members with ^rep

0

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.

0

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.

1 comment

0

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.