How to equally distribute plates?
So I'm trying to make a "Plates of Fate" type game and I got stuck on the part where I have to give each player their own plate and teleport them to their plate. This is what I managed to get so far but it only clones one plate and doesn't teleport the players.
01 | local plates = serverstorage:WaitForChild( "Plates" ) |
02 | local plateholder = game.Workspace:WaitForChild( "Plates" ) |
03 | local players = game:GetService( "Workspace" ).Players.Value |
05 | function addplate(player) |
06 | local allplates = plates:GetChildren() |
07 | local newplate = allplates [ math.random( 1 , #allplates) ] :clone() |
08 | newplate.Parent = workspace.Plates |
09 | newplate.Player.Value = player.Name |
20 | for _, player in pairs (game.Players:GetPlayers()) do |
21 | if player and player.Character then |
22 | local humanoid = player.Character:WaitForChild( "Humanoid" ) |
23 | if humanoid and humanoid.Health > 0 then |
24 | table.insert(contestants, player) |
28 | if #contestants > = 2 then |
31 | statustag.Value = "Waiting for Players" |
38 | statustag.Value = "Loading Plates" |
40 | plateholder:ClearAllChildren() |
42 | for _, player in pairs (contestants) do |
44 | statustag.Value = "Plates Loaded!" |
48 | local roundplates = plateholder:GetChildren() |
49 | for _, player in pairs (contestants) do |
50 | if player and player.Character and #roundplates > 0 then |
51 | local torso = player.Character:WaitForChild( "Torso" ) |
52 | local humanoid = player.Character:WaitForChild( "Humanoid" ) |
53 | local spawn = plateholder:FindFirstAncestor(player) |
54 | if spawn and torso and humanoid then |
56 | humanoid.WalkSpeed = 16 |
57 | torso.CFrame = CFrame.new(spawn.Position + Vector 3. new( 0 , 3 , 0 )) |
59 | local matchtag = Instance.new( "StringValue" ) |
60 | matchtag.Name = "MatchTag" |
61 | matchtag.Parent = player.Character |