Idea about making Wheel of Fortune (Spinning Wheel)

Hi Guys, so I was playing a game and I saw Wheel of Fortune, which is basically a spinning wheel. I was wondering how to make that. I mean it should reward the prize on which it lands. I don’t need script, just a simple idea.

Thanks :slight_smile:

1 Like

You can rotate the part using TweenService.

I mentioned rn, sorry for late mentioning, I need help regarding it should reward the prize according on which it lands. It’s all about Angles I guess but I don’t have much idea.

This might be able to help. The example uses a 2d wheel ui on the screen and with the players mouse, they move it around to select which slot they want to pick. You will have to adjust the wheelUI and mouselocation though to make it fit in 3d space.

local rewardsTable = {
	[1] = "100$",
	[2] = "200$",
	[3] = "300$",
	[4] = "400$",
	[5] = "500$",
}

local function getSlot(angle : number, wheelSizeOffset : number) : number
	angle = math.fmod(angle + wheelSizeOffset / 2, 360)
	return math.floor(angle / wheelSizeOffset) + 1
end

local function convertTo360(angle : number) : number
    return (angle >= 0) and angle or angle + 360
end

local wheelUI -- ui
local wheelSizeOffset : number = 360 / #rewardsTable
local mouseLocation = UserInputService:GetMouseLocation()
local wheelCenterPosition = (wheelUI.AbsolutePosition + (Vector2.new(wheelUI.AbsoluteSize.X * 0.5, (wheelUI.AbsoluteSize.Y * 0.5) + 36)))
local thetaInDegrees = 360 - convertTo360(math.deg(math.atan2(-(mouseLocation.X - wheelCenterPosition.X), -(wheelCenterPosition.Y - mouseLocation.Y))))

local key = getSlot(thetaInDegrees, wheelSizeOffset)

print(key) --key is the corresponding slot on the rewards table
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.