A while ago I created a clickable spinning wheel that uses CFrame to rotate it. But now it's become a problem due to excessive click spam. I could make the MaxActivationDistance 0, then wait a bit and go back to 32, but most of the time there are accidental spins. I want to use a button instead so that spam is prevented (Only I can spin the wheel). Here is the code for the actual wheel:
function onclicked()
game.Workspace.Spin:Play()
for i=1,20 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-math.random(),0)
wait(0.0001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.08,0)
wait(0.0001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.08,0)
wait(0.0001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.08,0)
end
for i=1,20 do
wait(0.001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.07,0)
wait(0.001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.07,0)
wait(0.001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.07,0)
end
for i=1,15 do
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.04,0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.04,0)
end
for i=1,15 do
wait(0.001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.03,0)
wait(0.001)
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,-.03,0)
end
end
script.Parent.ClickDetector.MouseClick:connect(onclicked)
What I am trying to achieve is that when you click that spin button, the wheel will spin.

2 comments
Why have you got 2 lines the same for each for?
I'm not targeting that part, but I just want to make sure that the wheel does not stop at the same spot every spin. What I am saying is I need a button that CFrames the wheel itself instead of clicking the wheel.