I have a value. It is known as isPlaying. How can I get these players and teleport them each to a random brick in a certain model without 2 on the same teleport brick?
My attempt:
P1 = game.Players:GetChildren() P2 = P1:IsAncestorOf("Playing") P2.Character.Torso.CFrame = randomMap.Part.CFrame --Randompart.CFrame???
I still don't understand how to do the 2nd half. Thanks if you help.
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. :)