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

How do use Math.Random help?

I'm trying to make the Script change the name of a Part to one of the randomly selective name in the Table.

myTable = {"Bob","Mike" ,"Jack"}--Here my table
part = script.Parent

while true do 
	wait(1)
part.Name = myTable[math.random(1,#myTable)]--Here where I want my part name to change to random name of the table.
end

I just started to learn Scripting and I'm currently playing around with Math.random but I'm having some trouble on how to use Math.Random. All answer are appreciated! :)

3 comments

2

Try taking the .v off

0

Already try that but it does nothing, Thanks for try though :)

0

I apologize Timster111 you were right my bad.

1 answer

✓ Accepted answer

V is a nil value. Get rid of it.

myTable = {"Bob","Mike" ,"Jack"}--Here my table
part = script.Parent

while true do 
    wait(1)
part.Name = myTable[math.random(1,#myTable)]--Here where I want my part name to change to random name of the table.
end

Works in my studio.

2 comments

0

Omg I'm So Stupid. My Script was disable no wonder it didn't work But thanks for helping me out mate!

0

Yeah. No problem.

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