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
- Insert a Part. A long thin one makes a good spinning bar.
- Add a Script inside the Part and paste the code.
- Play. The part turns without stopping.
Change it
- A negative DEGREES_PER_SECOND spins it the other way.
- Use AXIS = Vector3.new(1, 0, 0) to roll it like a wheel.
- Using deltaTime keeps the speed the same on fast and slow computers.
- Combine with the kill brick script to make a spinning hazard.
More in World and effects
More Roblox tools
- Shirt and pants templatesFree Roblox clothing templates to download: hoodies, jerseys, jeans, joggers and more.
- Robux tax calculatorWork out what you receive after the marketplace fee, or what to charge.
- Robux to USD calculatorConvert earned Robux to dollars at a DevEx rate you can edit.
- Shirt and pants template makerColour each panel of the 585×559 clothing template and download it.
- Username generatorGenerate usernames that fit the 3–20 character rule.