I am trying to make a simple spinner that rotates when you click a button.
There is probably an easier way to do this, but I can’t think of one.
The problem is that when the spinner rotates, I need to know the final rotation to see which item it is pointing to and the rotation doesn’t reset back to 0 at 360 degrees so it is always a really high number. I’m not sure how to check if something is a multiple or not, but I think that is what I need unless I am totally on the wrong track here.
I tried resetting the degrees to 0 each time it reaches 360 but that doesn’t work either.
Here is the script:
local button = script.Parent
local arrow = script.Parent.Parent.Arrow
local ui = script.Parent.Parent.Parent.Parent:WaitForChild("PlayerGui")
local players = ui:WaitForChild("Players")
local pb1 = players.Player1.TextButton
local pb2 = players.Player2.TextButton
local pb3 = players.Player3.TextButton
local pb4 = players.Player4.TextButton
local pb5 = players.Player5.TextButton
local pb6 = players.Player6.TextButton
local pb7 = players.Player7.TextButton
local pb8 = players.Player8.TextButton
local question = ui:WaitForChild("Question")
button.MouseButton1Click:Connect(function()
for i = 0, 60 do
arrow.Rotation = arrow.Rotation + 30
wait(0.001)
if arrow.Rotation == 360 then
arrow.Rotation = 0
end
end
for i = 0, 18 do
arrow.Rotation = arrow.Rotation + 20
wait(0.001)
if arrow.Rotation == 360 then
arrow.Rotation = 0
end
end
for i = 0, 30 do
arrow.Rotation = arrow.Rotation + 12
wait(0.001)
if arrow.Rotation == 360 then
arrow.Rotation = 0
end
end
for i = 0, math.random(5,115) do
arrow.Rotation = arrow.Rotation + 3
wait(0.001)
if arrow.Rotation == 360 then
arrow.Rotation = 0
end
end
pb1.Visible = true
pb2.Visible = true
pb3.Visible = true
pb4.Visible = true
pb5.Visible = true
pb6.Visible = true
pb7.Visible = true
pb8.Visible = true
if arrow.Rotation >= 0 and arrow.Rotation < 62 then
question.Frame.Frame.Category.Text = "ON THE ROAD"
question.Frame.Frame.Question.Text = "Find a BLUE car"
question.Enabled = true
end
if arrow.Rotation >= 62 and arrow.Rotation < 136 then
question.Frame.Frame.Category.Text = "FIND A WORD"
question.Frame.Frame.Question.Text = "Find a word that starts with C"
question.Enabled = true
end
if arrow.Rotation >= 136 and arrow.Rotation < 214 then
question.Frame.Frame.Category.Text = "MUSIC"
question.Frame.Frame.Question.Text = "Can't buy me ____"
question.Enabled = true
end
if arrow.Rotation >= 214 and arrow.Rotation < 291 then
question.Frame.Frame.Category.Text = "NAME GAME"
question.Frame.Frame.Question.Text = "Name a celebrity whos first name starts with C"
question.Enabled = true
end
if arrow.Rotation >= 291 and arrow.Rotation < 359 then
question.Frame.Frame.Category.Text = "LAST WORD"
question.Frame.Frame.Question.Text = "Think of the longest word that starts with the letter T"
end
end