Get the number of parts in the model you could do that and get a random number by doing:
local randomNum = math.random(#modelName)
Say if your model has 50 parts, this will generate a random number between 0 and 50, now to get the player onto the part, you should give the parts a specific name that way you can teleport them like so:
p2.Character.Torso.CFrame = modelName["specificName"..tostring(randomNum)].CFrame
Please note, in the wiki they say that this will not give out a random number for the reason that it will take the previous number into account. So in order to get a truly random number, you will have to set the seed. In the end, it should be something like so:
math.randomseed(tick())
local randomNum = math.random(#modelName)
p2.Character.Torso.CFrame = modelName["specificName"..tostring(randomNum)].CFrame
It could not work, since i have not tested it. But if you have any problems, feel free to comment.
[EDIT]
You want to get all the players and put each on a random part. Easy, just use
for _,player in pairs(game.Players:GetChildren()) do
local findPlayerInWork = game.Workspace:FindFirstChild(player.Name)
if findPlayerInWork then
sendPlayerToPart(findPlayerWork)
end
end
function sendPlayerToPart(plr)
math.randomseed(tick())
local randomNum = math.random(#modelName)
plr.Character.Torso.CFrame = modelName["specificName"..tostring(randomNum)].CFrame
end
Again, not sure if it works i haven't tested it in Roblox Studio. But i think it should work. :)
2 comments
Sorry, I also should mention I want to get ALL players to teleport and each to be on a different random brick. Not being mean, but is there a way to do that?
I edited my Answer. Hope it helps. :)