I am currently working on a HG game. I am trying to move everyone in the game(or on a certain team) and move them all to different pods. I literally have no idea how to go about this and if anyone can help it will be very useful. Please! This is all have so far which is a mess.
`` players = game.Players:GetChildren()
one = players[math.random(1, #players)]:MoveTo(part.Position) one.TeamColor = TeamColor.new("Dark blue") two = players[math.random(1, #players)]:MoveTo(part.Position) two.TeamColor = TeamColor.new("Dark blue") three = players[math.random(1, #players)]:MoveTo(part.Position) three.TeamColor = TeamColor.new("Dark blue") four = players[math.random(1, #players)]:MoveTo(part.Position) four.TeamColor = TeamColor.new("Dark blue")
end
``
Make a table for the parts. Make sure to put the parts in some kind of folder. Also if the player spawns inside the part then add at the end of line 10 " + Vector3.new(0,5,0)"
wait(4) local parts = {} for _,part in pairs(path to parts:GetChildren()) do table.insert(parts,part) end for _,plr in pairs(game.Players:GetPlayers()) do local partchosen = parts[math.random(1,#parts)] local char = plr.Character or plr.CharacterAdded:wait() char.HumanoidRootPart.CFrame = partchosen.CFrame for i,part in pairs(parts) do if part == partchosen then table.remove(parts,i) end end end
Problem | Solution |
---|---|
You’re trying to use the MoveTo method on the Player object, which will error since the Player class doesn’t have this method. |
Call the MoveTo method on the Character . (Not recommended) |
You’re trying to create a new TeamColor with a nonexistent global variable. |
The TeamColor constructor is BrickColor.new() . |
You used GetChildren on Players , which can error if you have items that aren’t Player objects. |
Use the Players:GetPlayers() method to get the children which are ONLY Player objects. |