#Help with trigonometry

1 messages · Page 1 of 1 (latest)

wooden kettle
#

tri-gon-o-metry

tri = triangle
gon = shape
o = of
measurement

measurement of triangle shapes

heady summit
#

i know that

wooden kettle
#

This guide is pretty good at understanding it

heady summit
#

i know the basics of trigo..

wooden kettle
#
for i = 1, 7 do
    local formula = i * ((math.pi*2)/7)
    local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)
    
    local part = Instance.new("Part")
    part.Anchored = true
    part.Size = Vector3.new(1, 1, 1)
    part.Position = position
    part.Parent = workspace
end
#

^ creates a circle with parts

#

roughly the same idea

heady summit
#

mhm. So in this case,

#

I'd prob need to do:

#

for i = 1,#Players:GetPlayers(), right?

wooden kettle
#

yes

heady summit
#

[that command would only run when more than 1 person is in server]

wooden kettle
#

just put :GetPlayers() in a variable

#

your going to use it multiple times anyways

wooden kettle
#

in local formula

heady summit
#

Mhm

wooden kettle
#

you basicly plugin your playercount there

#

because the for loop is 7 cubes

heady summit
#

That's the 'indicator' for how many bricks to create?

wooden kettle
#

yes

heady summit
#

so the 7 there in the for i =1,7 do has to be the same number as that /7?

wooden kettle
#

yes

#

And afaik

#

If its just one

#

then it will work correctly

heady summit
#

very good.

wooden kettle
#

trig ~= triangles

#

trig == circles

wooden kettle
#

If the above needs any clarification:

#
for i = 1,7 do
local formula = math.pi*2/7*i
local x = math.cos(formula) * 10 -- radius
local z = math.sin(formula) * 10 -- radius again
local part = Instance.new("Part")
    part.Anchored = true
    part.Size = Vector3.new(1, 1, 1)
    part.Position = Vector3.new(x,5,z)
    part.Parent = workspace
task.wait()
end
#

someone "simplified" it

#

its simply the same

heady summit
#

true.

#
local Players = game:GetService("Players")
local exampleObject = game.Workspace.exampleObject 

local function tpPlayers()
    local TotalPlayers = #Players:GetPlayers()
    for i = 1, TotalPlayers do
        local formula = i * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)

        local part = Instance.new("Part")
        part.Anchored = true
        part.Size = Vector3.new(1, 1, 1)
        part.Position = position
        part.Parent = workspace    
    end
end

Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(Message)
        local messages = Message:Split(" ")
        if messages[1] == "!Circle" then
            if messages[2]:lower() == "all" then
                for _,player in pairs(Players:GetPlayers()) do
                    
                end
            end
        end
    end)
end)
#

okay

#

i have this now

#

so what I need to do is

wooden kettle
#

that *5 in the formula

#

is how spaced out it is

#

you could add that as a parameter to your admin system

heady summit
#
local Players = game:GetService("Players")
local exampleObject = game.Workspace.exampleObject 

local function tpPlayers(player)
    local TotalPlayers = #Players:GetPlayers()
    for i = 1, TotalPlayers do
        local formula = i * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)

        local part = Instance.new("Part")
        part.Anchored = true
        part.Size = Vector3.new(1, 1, 1)
        part.Position = position
        part.Parent = workspace    
        player.Character:PivotTo(part)
        part:Destroy()
    end
end

Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(Message)
        local messages = Message:Split(" ")
        if messages[1] == "!Circle" then
            if messages[2]:lower() == "all" then
                for _,player in pairs(Players:GetPlayers()) do
                    tpPlayers(player)
                end
            end
        end
    end)
end)



#

should this work?

wooden kettle
#

well right now its just going to make parts

#

but afaik yes

heady summit
#

tho i dont really need the parts

#

is it possible to still spawn the players in a circle without the need of creating the parts

wooden kettle
#

the pivotto thing seems a little off

#

all you need is two vector3s and your good

#

Player.Character.PrimaryPart.CFrame = CFrame.new( pos1, pos2 )

#

and it should point your character in the correct direction

#

make sure you only supply two vector3 values

heady summit
#
local function tpPlayers(player)
    local TotalPlayers = #Players:GetPlayers()
    for i = 1, TotalPlayers do
        local formula = i * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)
        player.Character.PrimaryPart.Position = position
    end
end
wooden kettle
#
local function tpPlayers(player)
    local TotalPlayers = #Players:GetPlayers()
    for i = 1, TotalPlayers do
        local formula = i * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)
        local charpos = player.Character.PrimaryPart.Position
        player.Character.PrimaryPart.CFrame = CFrame.new( charpos, position )
    end
end
heady summit
#

same thing right?

wooden kettle
#

no

#

you need to use cframe for this

heady summit
#

why does it matter

wooden kettle
#

Do you want the players to face the spawner?

heady summit
#

mhm

wooden kettle
#

simply just setting the position alone will not

heady summit
#

hm

#

but how do I face them

#

to look at a given object

#

should I use lookAt?

wooden kettle
#

thats what its doing

#

by providing two vector3 values

#

This is using the same method I just showed you

heady summit
#

well

#

when i tested it

#

they didnt face to that part

#
local Players = game:GetService("Players")
local exampleObject = game.Workspace.exampleObject 

local function tpPlayers(player)
    local TotalPlayers = #Players:GetPlayers()
    for i = 1, TotalPlayers do
        local formula = i * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)
        player.Character.PrimaryPart.CFrame = CFrame.new(exampleObject.Position,position)
    end
end
#

so i changed

wooden kettle
#

does that work?

heady summit
#

not at all, ill now show a video.

#

Okay, here is the video:

#

It seems to work but has few issues.

#
local function tpPlayers(player)
    local TotalPlayers = #Players:GetPlayers()
    for INDEX,PLAYER in pairs(Players:GetPlayers()) do
        local formula = INDEX * ((math.pi*2)/TotalPlayers)
        local position = Vector3.new(math.cos(formula) * 5, 5, math.sin(formula) * 5)
        PLAYER.Character.PrimaryPart.CFrame = CFrame.new(exampleObject.Position,position)
    end
end
#

maybe this can help

heady summit
#

to spawn players

#

in a circle way

#

facing a part

#

the only issue i have now

#

is that it spawns them in circle but not surrounding the part

#

My command now: