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.
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
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
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?
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
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