If you’ve never watched Wheel of Fortune or some other game with a massive wheel, the
point of the wheel is it to spin and land on a random tile.
I’m not looking for a script to make the wheel (I already have a decal for that): I’m looking for a script that would spin the wheel on click.
My only issue is going about randomly generating how long the wheel will spin: my guess is that the wheel would randomly generate a random number in CFrame and then rotate that many times. How would I go about doing so?
EDIT: Another problem: would it be possible to weld a wheel to spin as well using a welding script? If I wanted to add those little pegs on the sides that the pointer would fall on, would it be possible to weld the wheel to these pegs?
For your first question about making a randomly spinning wheel. You can use mouse.Target to get what your mouse is clicking on or you could use a clickDetector. You can use math. random(1, someNumber) to get how long you want it to spin for. Then you could CFrame the wheel a little bit at time until your random number is reached.
You can use CFrame.Angles on the axis you want it to spin by a random starting speed, then you will decrease the angular speed over time at a rate you specify (deceleration):
Here’s some pseudo-code:
local r = 2
local v = math.random(20, 50)
con = game:GetService("RunService").RenderStepped:Connect(function(dt)
wheel:SetPrimaryPartCFrame(wheel:GetPrimaryPartCFrame() * CFrame.Angles(0, dt * v, 0)) -- if your wheel is a model
v = math.max(v - (dt * r), 0)
if v == 0 then
This is if you’re running it in a local script
EDIT: I clamped the angular speed at a minimum of 0 and disconnected the event when it reaches 0
Thanks! This is incredibly useful, but I know from prior knowledge that RenderStepped can only be used in Local Scripts. Is it possible to translate it into a normal script so everyone in the server can see?
Stepped is an alternative, which fires before every physics update, but using RenderStepped on the client should be a little smoother. You can notify all clients when you click the wheel and spin on their clients to make it a little smoother.
If you don’t want to do all of that, you can just use Stepped on the server