jellolemo
(jellolemo)
November 19, 2025, 4:21pm
1
can someone help me with CFrames, it works but I think it can be more simple (especially the +position part):
local partA = script.Parent
local partB = partA:Clone()
partB:ClearAllChildren()
local offset = CFrame.new(0,partA.Size.Y/2, 0)
local angle = CFrame.Angles(math.rad(45),math.rad(45),math.rad(45))
local targetCFrame = partA.CFrame * angle * offset
partB.CFrame = targetCFrame
partB.Position += offset.Position
partB.Parent = workspace
1 Like
WeeklyShoe
(WeeklyShoe)
November 19, 2025, 4:33pm
2
the only thing i can think of is to add offset.Position to targetCFrame instead of doing it separately, which would reduce a line of code
1 Like
jellolemo
(jellolemo)
November 19, 2025, 4:47pm
3
i updated my code:
~local partA = script.Parent
local partB = partA:Clone()
partB:ClearAllChildren()
local offset = CFrame.new(0,partA.Size.Y, 0)
local angle = CFrame.Angles(math.rad(45),math.rad(45),math.rad(45))
local targetCFrame = partA.CFrame * angle * offset
local thing = partA.CFrame * offset * angle * partA.CFrame:ToObjectSpace(partB.CFrame)
partB.CFrame = thing
partB.Parent = workspace
ok so I was kinda unclear but I have this problem when rotatating:
without rotating:
Dammio_6
(whatever)
November 19, 2025, 4:49pm
4
I agree with you, @WeeklyShoe . Just reduce your lines of code. For example, you can write:
partB.CFrame = CFrame.new(0,partA.Size.Y/2, 0)
Instead of that
1 Like
jellolemo
(jellolemo)
November 19, 2025, 4:50pm
5
That sadly won’t work with angles, but thanks anyways
Dammio_6
(whatever)
November 19, 2025, 4:53pm
6
I will test that and reply later…
1 Like
2112Jay
(2112Jay)
November 19, 2025, 5:15pm
7
local partB = script.Parent:Clone() partB:ClearAllChildren()
partB.CFrame = script.Parent.CFrame * CFrame.Angles(math.rad(45),
math.rad(45), math.rad(45)) * CFrame.new(0, script.Parent.Size.Y/2, 0)
partB.Parent = workspace
1 Like
jellolemo
(jellolemo)
November 19, 2025, 5:21pm
8
Thank you, but it still isn’t perfect because it doesn’t sit on top. Any ideas on how to fix that?
like this:
2112Jay
(2112Jay)
November 19, 2025, 5:24pm
9
Well, I can guess.. I need to work with things to be sure.
local part = script.Parent:Clone() part:ClearAllChildren()
local angle = CFrame.Angles(math.rad(45), math.rad(45), math.rad(45))
part.CFrame = script.Parent.CFrame * angle +
angle:VectorToWorldSpace(Vector3.new(0, script.Parent.Size.Y/2, 0))
part.Parent = workspace
jellolemo
(jellolemo)
November 19, 2025, 5:28pm
10
It’s not perfect, but it sure is a step in the right direction, thank you for helping and good luck with your work
2112Jay
(2112Jay)
November 19, 2025, 5:28pm
11
This is what happens to me too.. lol, keep trying you’ll get it.
Let’s see here.. Trying a different approach..
local part = script.Parent:Clone() part:ClearAllChildren()
local angle = CFrame.Angles(math.rad(45), math.rad(45), math.rad(45))
part.CFrame = script.Parent.CFrame * angle +
script.Parent.CFrame.UpVector * (script.Parent.Size.Y/2)
part.Parent = workspace
1 Like