I would like to know how to use position in math.random, what I mean is it would loop through a folder in workspace and pick a random onem and make the position of an object the position of the random object like this
Local folder = gane.Workspace.Folder
for i, v in pairs(folder:GetChildren()) do
-- loop through and pick a random one
end
game.Workspace.Object.Position = --random.Position
--Change a and b to any number you want, make sure b is greater
local pos1 = math.random(a,b)
local pos2 = math.random(a,b)
local pos3 = math.random(a,b)
game.Workspace.Object.Position = Vector3.new(pos1,pos2,pos3)
If you want the position to be random again, put in in a loop.
Well what Im going or is it will loop through a folder get a random part thats in that folder and gets its position then set the game.Workspace.Object.Position to the random objects position
local children = folder:GetChildren() -- get a table containing all the parts in the folder
local randomChild = children[math.random(1, #children)] -- index a random part from the table
game.Workspace.Object.Position = randomChild.Position -- set object position to random child position