How would I change this so when It makes part it makes them based on the orientation of the OriginPart

So I have a game with a crater system as you can see.

Now I need to make it so when I change the CFrame of the OriginPart to point towards something else that it makes the Parts around the part. And they match its rotation. There might be away I can do this all ready but I was wondering if any of you know a good way to do it.

If you have any questions feel free to ask!

show code

1 Like

Oh yeah!!! Srry i forgot

function Createpart() -- this is what creates a part
	local part = Instance.new("Part")
	part.Anchored = true
	part.Size = Vector3.new(1,1,1)
	part.Parent = workspace
	return part
end


local function crater(po, amount, spaceApart, downAmount) 
	local rotate = 360 / amount
	local Origin = po
	
	local originPart = Instance.new('Part') -- create the origin part
	originPart.Size = Vector3.new(1,1,1)
	originPart.Position = Origin
	

	
	for t = 0, amount, 1 do
		-- set the po2
		local Part = Createpart() -- this creates the part
		Part.Position = originPart.Position + Vector3.new(math.cos(math.rad(t) * rotate) * spaceApart, -downAmount ,math.sin(math.rad(t) * rotate) * spaceApart) -- this is what rotates the part we create. This is what I need to change so it will rotate around using the origins CFrame

You’re going to have to set the parts cframe instead of just the position. Can you show me the logic for finding the origin part?

Oh the origin part is just a part in a certain position. I just use vector3 so yeah

How are you getting that position though? Because you also need that positions normal to orient all the parts to the correct surface

Im just using a function.
And one of the functions variables is “PO”
which is a vector3. Just a straight up vector3.

Why do U need this? I’m trying to change it depending on the origin parts CFrame not the position

Because the only way to get the CFrame is from where you’re getting the position

just take it from the origin part. dont worry about how its a new part. Ima change the CFrame later.
Right now I just need it to do what I said

Ok but see the thing is you can’t get the orientation just with the position. Somewhere in your code you have to be getting the position, and in that same part you can probably also get the CFrame. So i’m asking where that part is

The part is at the the position (1,14,1) if thats what you mean.

I dont really understand what your saying

im kinda confused, could you elaborate a little more?

edit: i dont know what you mean by “makes them based on the orientation of the OriginPart” and “match it’s rotation” do their orientations just become the rotation?

OHH. alright I gotchu:

function Createpart()
	local part = Instance.new("Part")
	part.Anchored = true
	part.Size = Vector3.new(1,1,1)
	part.Parent = workspace
	return part
end

local Part45degrees = 8
local Maxparts = 14
local Origin = script.Parent.CFrame
local Multiplier = 3

for i = 1,Maxparts,1 do
	local Part = Createpart()
	local x = math.cos(math.rad(i) * (45 / (Maxparts / Part45degrees)))
	local y = math.sin(math.rad(i) * (45 / (Maxparts / Part45degrees)))
	Part.CFrame = Origin * CFrame.new(x * Multiplier,0,y * Multiplier)
end

(tell me if this is what you meant)

I tried this. It does the same thing it originally did

can you give more elaboration on what you’re trying to do? I’m confused on what you’re trying to do. I’m not that smart :sweat_smile:

So basically im taking the lookVector3 of the ORIGINPART which is a variable/Part that you can see in the script.

I want to make a crater in the direction that it is facing.
I all ready have code that makes parts form around a certain position, But i need them to form and point towards the lookvector3. And then move downwards into that direction