Make parts angle out relative to player?

So basically I made a circle of parts but aren’t that good with math and need some help on how I would make a circle of parts each angle out like away from the player as in this picture below.

Basically the parts are all angled out relative to his player and I was wondering how to do the math for this?

Here’s my circle and code for it already.

image

local Radius = 12
		local NumberOfParts = 30
		local Circle = math.pi * 2
		local DebrisTable = {}
		for  i = 1,NumberOfParts do
			local angle = Circle / NumberOfParts * i
			local Xpos = math.cos(angle) * Radius
			local Ypos = math.sin(angle) * Radius
			local Pos = Player.Character.HumanoidRootPart.Position + Vector3.new(Xpos,0,Ypos)
			local Results = Library.Functions.Raycast(Pos,Vector3.new(0,-5,0),{Player.Character,Parts})
			if Results then
				local Debris = Instance.new("Part",workspace)
				table.insert(DebrisTable,Debris)
				Debris.Size = Vector3.new(2,2,2)
				Debris.Anchored = true
				Debris.BrickColor = Results.Instance.BrickColor
				Debris.Material = Results.Instance.Material
				Debris.Position = Results.Position - Vector3.new(0,3,0)
				Debris.Orientation = Vector3.new(math.random(-360,360),math.random(-360,360),math.random(-360,360))
				local Tween = Library.Functions.Tween(Debris,{Position = Debris.Position + Vector3.new(0,3.5,0)},0.25)
				Tween.Completed:Connect(function() Library.Functions.Tween(Debris,{Position = Debris.Position + Vector3.new(0,-0.5,0)},0.25) end)
			end
		end
2 Likes

lots see if i can get this right lol

start off by having a block with the same cframe as your character.

local cframe1 = Player.Character:GetPrimaryPartCFrame()

then you are going to rotate it’s cframe about its y axis according to its position around the ring (with the angle u already defined)

local cframe2 = cframe1*CFrame.Angles(0,angle,0)

then you can move the block outwards according to its new orientation

local cframe3 = cframe2:ToWorldSpace(CFrame.new(0,0,radius)

then you can rotate it about its x axis to angle it outwards like in the first pic

local cframe4 = cframe3*CFrame.Angles(math.pi/4,0,0)

and then instead of setting the position and orientation like you have it, just set the debris CFrame to cframe4

you can do it all in 1 line however and it will look like this:

local debrisCFrame = player.Character:GetPrimaryPartCFrame()*CFrame.Angles(0,angle,0):ToWorldSpace(CFrame.new(0,0,radius)*CFrame.Angles(math.pi/4,0,0)

Debris.CFrame = debrisCFrame

try this and lemme know if anything goes wrong lol

Replace this two lines with:

Debris.CFrame = CFrame.new(Results.Position-Vector3.new(0,3,0), Player.Character.Head.Position) 
--First argument is position, and second is look at position. So it spawns on needed position and looks at player`s head. Ez

Replyed wrong, sorry.

looool thats alot easier than my solution

1 Like

Thanks yeah I was told by someone CFrame.LookAt or CFrame.new(Origin,LookAt) is the easiest way and it works thanks though.

1 Like

thanks yeah I figured out the one line of code setting the CFRame and position with angles I just wasn’t aware that you could put a position in a CFrame.new() before thanks.