Hi, I’m currently making a building system and I want to rotate the part 90 degrees when the player presses R. But when the player presses R it rotates the part until the player moves their mouse again because the rotation gets set back to normal. I believe this is because I’m using :SetPrimaryPartCFrame on 2 different lines, one of them rotating the part and the other one setting the rotation back to it’s original rotation. So to counter this I want to know how to get CFrame.Angles so I can apply it to the line that sets the rotation back to it’s original state. Here’s my code:
local PosX = math.floor(castRay.Position.X / GridSize) * GridSize + GhostItem.PrimaryPart.Size.X/2
local PosY = math.floor(castRay.Position.Y / GridSize) * GridSize + GhostItem.PrimaryPart.Size.Y/2
local PosZ = math.floor(castRay.Position.Z / GridSize) * GridSize + GhostItem.PrimaryPart.Size.Z/2
GhostItem:SetPrimaryPartCFrame(CFrame.new(PosX,PosY,PosZ))
UserInputService.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
GhostItem:SetPrimaryPartCFrame(GhostItem.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0))
end
end)