I scripted one for one of my games. Here’s how I did it:
-- This table contains all the prize data. Stars is the prize, MinPos and MaxPos is the rotation value of the arrow in the gui for that prize segment of the wheel. (you will probably need to adjust these values to match your own prize segments)
local Fortune={{Stars=1000, MinPos=1352, MaxPos=1393}, {Stars=300, MinPos=1172, MaxPos=1214},
{Stars=150, MinPos=1127, MaxPos=1169}, {Stars=100, MinPos=1037, MaxPos=1078},
{Stars=50, MinPos=1082, MaxPos=1123}, {Stars=50, MinPos=1263, MaxPos=1300},
{Stars=25, MinPos=1219, MaxPos=1259}, {Stars=25, MinPos=1308, MaxPos=1348} }
-- The following just determines which prize the player is going to win.
local Rnd=math.random(1, 100) -- Choose a random number to determine prize
local WinningLine
if Rnd>95 then WinningLine=Fortune[1]--1000 Stars
elseif Rnd<96 and Rnd>85 then WinningLine=Fortune[2] -- 300 Stars
elseif Rnd<86 and Rnd>69 then WinningLine=Fortune[3]-- 150 Stars
elseif Rnd<70 and Rnd>49 then WinningLine=Fortune[4]-- 100 Stars
elseif Rnd<50 and Rnd>25 then local r=math.random(1, 2) if r==1 then WinningLine=Fortune[5] else WinningLine=Fortune[6] end -- 50 Stars
elseif Rnd<26 then local r=math.random(1, 2) if r==1 then WinningLine=Fortune[7] else WinningLine=Fortune[8] end -- 25 Stars
end
-- This line decides the final landing position of the arrow (I used min and max pos so the arrow didn't land on the
-- exact same spot of each segment every time)
local RandPos=math.random(WinningLine.MinPos, WinningLine.MaxPos)
-- Added the winner to a table including what their prize is so when they click a claim button on their gui I can refer
-- to this table and give them their winnings.
table.insert(FortuneWheelWinners, {Player.UserId, WinningLine.Stars})
-- Fire the client to show the fortune wheel gui, passing the Rotation Value of the arrow so the wheel knows where to stop.
UpdateClient:FireClient(Player, "FortuneWheel", RandPos)
Client Gui Code Segment:
-- This is the tween setup that spins the arrow for 5 seconds and lands on the passed Rotation Value from the above code
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(Wheel, tweenInfo, {Rotation = FinalRot})
tween:Play()