I think y’all know that there are some models with a Wheel that you can spin. With that, I wanted to know what scripts I can put to this one.
*(Image from my project)
I have no idea some type of stuffs people say like “You should use CFrame” (I don’t know what CFrame means) because I don’t have that ability of programming, only building.
If you guys know what scripts I can put, I really appreciate your amazing help.
I have made a sample script, as full rotations with TweenService are a bit tricky. (Tween will always use shortest way to reach its goal, so in best case scenario you will only achieve half turn). To make full rotations you will need multiple tweens. I am also assuming you want your “Wheel of fortune” to slow down? Here is what I came up with (parent the script to the part, and make sure it is Anchored):
local part = script.Parent
local TweenService = game:GetService("TweenService")
local slowestSpeed = 1
local spinStep = math.pi/36 --three steps per section
local friction = 0.5 --percent per step
local function Spin(initialSpeed)
if initialSpeed <= slowestSpeed then
return
end
local speed = initialSpeed
local style = TweenInfo.new(1/speed,Enum.EasingStyle.Linear)
local target = {CFrame = part.CFrame * CFrame.Angles(0,spinStep,0)}
local tween = TweenService:Create(part,style,target)
local connection
local function OnCompletion()
connection:Disconnect()
speed = speed - (initialSpeed*friction/100)
if speed < slowestSpeed then
return
end
style = TweenInfo.new(1/speed,Enum.EasingStyle.Linear)
target = {CFrame = part.CFrame * CFrame.Angles(0,spinStep,0)}
tween = TweenService:Create(part,style,target)
connection = tween.Completed:Connect(OnCompletion)
tween:Play()
end
connection = tween.Completed:Connect(OnCompletion)
tween:Play()
end
Spin(50+math.random(50))
Change the rotation axis in both targets. It will be either CFrame.Angles(spinStep,0,0) or CFrame.Angles(0,0,spinStep) depending on the wheel initial orientation.