Skinstashery
Roblox
Home / Roblox / Studio script library / Spinning part
RB-004

Roblox spinning part script

A part that turns around steadily, like a fan blade or a spinning bar.

Script type
Script
Where it goes
Inside the Part
Category
World and effects

For your own game in Roblox Studio. Not for use in other people's games.

The code

-- Spinning part: turns the part around its own centre.

local DEGREES_PER_SECOND = 90
local AXIS = Vector3.new(0, 1, 0)   -- (0,1,0) turns it like a record player

local RunService = game:GetService("RunService")

local part = script.Parent
part.Anchored = true

local radiansPerSecond = math.rad(DEGREES_PER_SECOND)

RunService.Heartbeat:Connect(function(deltaTime)
	part.CFrame = part.CFrame * CFrame.fromAxisAngle(AXIS, radiansPerSecond * deltaTime)
end)

How to set it up

  1. Insert a Part. A long thin one makes a good spinning bar.
  2. Add a Script inside the Part and paste the code.
  3. Play. The part turns without stopping.

Change it

More in World and effects

All Roblox scripts

More Roblox tools