We use cookies on this site to enhance your user experience
Collapse Sidebar




The Rotation property determines the number of degrees by which a UI element is rotated, relative to the center of the parent UI element.

A UI element’s GuiObject/AnchorPoint does not influence the rotation of a UI element. In other words, you cannot change the center of rotation since it will always be in the center of the object. Additionally, this property is not compatible with GuiObject/ClipsDescendants. If some ancestor object has GuiObject/ClipsDescendants enabled and this property is nonzero, then descendant UI elements will not be clipped.

Code Samples

Spin GuiObject

This code sample rotates a parent GuiObject (such as a Frame) using a given rotation speed and the RunService/RenderStepped event.

local RunService = game:GetService("RunService")

local guiObject = script.Parent

local degreesPerSecond = 180

local function onRenderStep(deltaTime)
	local deltaRotation = deltaTime * degreesPerSecond
	guiObject.Rotation = guiObject.Rotation + deltaRotation 

Copycat Frame

This code sample shows how a UI element’s size, position and rotation can be copied without parenting a “copycat” to the original. It uses the Absolute-family of properties to orient a “copycat” Frame that covers on the screen space that the original does.

-- Place within a Frame, TextLabel, etc.
local guiObject = script.Parent

-- For this object to be rendered, it must be a descendant of a ScreenGui
local screenGui = guiObject:FindFirstAncestorOfClass("ScreenGui")

-- Create a copy
local copycat = Instance.new("Frame")
copycat.BackgroundTransparency = 0.5
copycat.BackgroundColor3 = Color3.new(.5, .5, 1) -- Light blue
copycat.BorderColor3 = Color3.new(1, 1, 1) -- White

-- Orient the copy just as the original; do so "absolutely"
copycat.AnchorPoint = Vector2.new(0, 0) 
copycat.Position = UDim2.new(0, guiObject.AbsolutePosition.X, 0, guiObject.AbsolutePosition.Y)
copycat.Size = UDim2.new(0, guiObject.AbsoluteSize.X, 0, guiObject.AbsoluteSize.Y)
copycat.Rotation = guiObject.AbsoluteRotation

-- Insert into ancestor ScreenGui
copycat.Parent = screenGui