Doesn't change Hitbox orientation

Hello,

I really don’t understand why this script:

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		if not rotationTimeout then
			if buildingEnabled and workspace:FindFirstChild("Placement") then
				rotationTimeout = true
				local object = workspace:FindFirstChild("Placement"):FindFirstChildWhichIsA("Model")
				object.Hitbox.Orientation = Vector3.new(object.Hitbox.Orientation.X, object.Hitbox.Orientation.Y-90, object.Hitbox.Orientation.Z)
			end
			task.wait(0.2)
			rotationTimeout = false
		end
	end
end)

doesn’t change Hitbox orientation even though i scripted it to do that, it does rotate all of the part, but doesn’t rotate the hitbox itself, why’s that?
image
It only changes the meshes orientation but not the Hitbox orientation.

Thanks for helping!

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		if not rotationTimeout then
			if buildingEnabled and workspace:FindFirstChild("Placement") then
				rotationTimeout = true
				local object = workspace:FindFirstChild("Placement"):FindFirstChildWhichIsA("Model")
				local currentCFrame = object.Hitbox.CFrame
				local newCFrame = currentCFrame * CFrame.Angles(0, math.rad(-90), 0)
				object.Hitbox.CFrame = newCFrame
			end
			task.wait(0.2)
			rotationTimeout = false
		end
	end
end)

Hey thanks for helping me!
I’ve tried this and I saw that it rotates only when it isn’t being moved, as I’m creating a building system. How could I fix the issue.

local result = MouseRaycast({clone})
if result and clone:FindFirstChild("Hitbox") then
	local halfSize = clone:FindFirstChild("Hitbox").Size.Y/2
	clone.Hitbox.CFrame = CFrame.new(result.Position.X, result.Position.Y+halfSize, result.Position.Z)

(Little snippet from the mouse tracking)

local hitboxRotation = CFrame.new() 

local result = MouseRaycast({clone})
if result and clone:FindFirstChild("Hitbox") then
	local halfSize = clone:FindFirstChild("Hitbox").Size.Y/2
	clone.Hitbox.CFrame = CFrame.new(result.Position.X, result.Position.Y+halfSize, result.Position.Z) * hitboxRotation

Where would I exactly use the hitboxRotation variable as I am pretty confused. As the rotation and moving events are different, so all they share is the CFrame.

before the userinputservice.inputbegan

Does the hitboxRotation has to have some kind of value inside it and not only CFrame.new() ?

you can, it really depends
fsdgfdsgdfsg

Then what is result.Position.Z) * hitboxRotation multiplying?

basically a transformation, like I said, it depends, you can keep it without any value

Sadly the issue is still the same.