How do I position players on a circle?

I am trying to position the players on the ends of the circle. The first player gets positioned correctly but I want the second player to be a little distant from the other player. The players end up being teleported in a line crossing the circle instead of all around the circle. How would I achieve this?

		for i,v in pairs(_G.Players) do
			local R = 14
			local Rot =  chairs.Circle.CFrame
	        Rot = Rot * CFrame.Angles(0,math.rad((360/#game.Players:GetPlayers())*i),0)
			Rot = Rot *,1,R)
1 Like

Couldn’t you just make a bunch of parts and group them, name them something like teleport1 teleport2 etc position them accordingly around the circle and then loop through them all I feel like that would be easier.

1 Like

That would work but I would rather do it this way for efficiency.

I would use math.tan.
Here’s a bit of pseudo-code to get you on your way.

for i, the players in the game do
 angleAmount = math.pi*2/#players
 movePlayer to (math.tan(angleAmount*i)*multiplier, yValue, 1*multiplier) + circleCenterPosition

I think this will work, but I haven’t tested it in real code.

Edit: this won’t work as written. I think I’m on the right track with math.tan, so I’ll keep updating this until a solution is found.


Hey, what does math.tan does exactly?

It gets the tangent of a number in radians.

Alright, here’s a completely new reply. I was kind of on the right track with math.tan, but other trigonometry functions are needed.

for i, the players in the game do
 angleAmount = math.pi*2/#players
 movePlayer to (math.sin(angleAmount*i)*multiplier, yValue, math.cos(angleAmount*i)*multiplier) + circleCenterPosition

Try something like this.

Getting an error: Unable to cast double to Vector3

local angleAmount = math.pi*2/#game.Players:GetPlayers()
local multiplier = 3
local yValue = 2
local pos = math.sin(angleAmount*i)*multiplier, yValue, math.cos(angleAmount*i)*multiplier + 14

it should be

pos =*i)*multiplier, yValue, math.cos(angleAmount*i)*multiplier) + Circle.Position

You need to construct the vector first.

1 Like

Changed and it worked, thanks!