Problem with rotation

I’m making a script that turns the mouse delta into object rotation, but a problem arises. It rotates the object in the local axes of rotation because of this, it is not convenient to do so. How could I rotate an object around global axes? Like in second screenshot.

image

Ctrl + L will toggle between the two

edit
didnt realize this was scripting support srry xD

I assume you’re writing a script to do this, if you want to do it in world space, multiply the rotation times the current cframe, not the other way around.

deltaRotation * currentCFrame

And how will this help me? I’ve tried a lot of things to do.

Can you send the script? It’s difficult to figure out where the issue is when you don’t provide it. I’m just going off of assumptions.

Rotation around Y-axis is good but around X-axis is weird

UserInputService.InputChanged:Connect(function(input, gameProcessed)
	--if gameProcessed then return end
	
	if input.UserInputType == Enum.UserInputType.MouseMovement and RotationMode then
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition

		rotateVector += Vector2.new(input.Delta.X, input.Delta.Y)
	end
end)

local function UpdateRotatePart(rotateVector)
	if not RotationPart or not LocalVisualPart then return end

	local x, y, z = Camera.CFrame:ToOrientation() -- This need for part look at player
	
	RotationPart.CFrame = CFrame.new(LocalVisualPart.Position)
	RotationPart.CFrame *= CFrame.fromOrientation(math.rad(rotateVector.Y), math.rad(rotateVector.X) + y, z)

	return
end