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

How do use Math.Random help?

Asked by 9 years ago

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! :)

2
Try taking the .v off Timster111 25 — 9y
0
Already try that but it does nothing, Thanks for try though :) UserOnly20Characters 890 — 9y
0
I apologize Timster111 you were right my bad. UserOnly20Characters 890 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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.

0
Omg I'm So Stupid. My Script was disable no wonder it didn't work But thanks for helping me out mate! UserOnly20Characters 890 — 9y
0
Yeah. No problem. nightmare13542 45 — 9y
Ad

Answer this question