Hey there Robloxians!
Last time I made a Topic called “What script can make a wheel spin?” in here, the Roblox DevForum.
With that, I got an answer a user called Sleazel and I got this:
“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))
(Sorry If have many “>”, it’s because when I copied the text script, the text came but not the same way)
But the thing is, the script was working but the Wheel was rotating to wrong direction and this was the result when I put the script:
He also said this when I posted the photo:
Change the rotation axis in both targets. It will be either
CFrame.Angles(spinStep,0,0)
orCFrame.Angles(0,0,spinStep)
depending on the wheel initial orientation.
And with that, I was pretty confused because I don’t have any experiences of programming or understading a thing called “CFrame”, I just have experiences of building.
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.
And I just told him the orientation to him
"The orientation from the wheel is 0, -90, 90"
And he never responded after that…
But being thinking more about the script that he gave in the Topic answer, the script doesn’t loop or can’t click to spin. And I finally realized that the part needed a thing called “ClickDetector”.
But I don’t know how a plaver can spin a wheel using the ClickDetector + what script for the Wheel to work.
Can someone help me out with this, please?
Thank you!
- Juan