I'm trying to find a certain block out of 3 blocks, using math.random
1 | local FolderForParts = game.Workspace.Folder |
2 | local PartNumber = math.random( 1 , 3 ) -- 3 Blocks in folder |
3 | local Part = --Finds the part |
The part names (just keeping it simple): Part1 Part2 Part3
You need to get the number of the part
1 | local FolderForParts = game.Workspace.Folder |
2 | local PartNumber = math.random( 1 ,#FolderForParts:GetChildren()) |
3 | local Part = FolderForParts:WaitForChild( "Part" .. tostring (partNumber)) |
This script transforms the selected number into a string and gets the selected part in the folder. P.S: With this script you can put as many parts as you want as long as they are numbered
I think this is what you want.
1 | local FolderForParts = game.Workspace.Folder:GetChildren() -- make a table of parts |
2 | local PartNumber = math.random( 1 ,#FolderForParts) -- 1 through length of table |
3 | local Part = FolderForParts [ PartNumber ] -- reference chosen part |
4 |
5 | print (Part.Name) |