My spinner system is choosing 2 of the 6 options available and sort of assigning them to a player…? Basically when they spin they get 1 of 2 options however it cycles through every option. For example, it always cycles between a colour and Nothing.
I get stuck in the Blue and Nothing loop quite frequently.
spinner script, local script inside a ScreenGui in StarterGui
local text = script.Parent.SpinnerText
local button = script.Parent.SpinnerButton
local waitTime = 0.1
local playbutton = script.Parent.Play
local objects = {"Nothing", "Orange", "Gold", "Blue", "Red", "Green"}
local spinCount = 55
local start = math.random(1, #objects)
local function nextObject()
if start == #objects then
start = 1
else
start += 1
end
return objects[start]
end
button.MouseButton1Click:Connect(function()
for i=spinCount, 0, -1 do
text.Text = nextObject()
if i <= 10 then
waitTime += 0.1
end
wait(waitTime)
waitTime = 0.1
end
-- text.TextColor3 = Color3.fromRGB(255, 176, 48)
-- wait(.5)
-- text.TextColor3 = Color3.fromRGB(0, 0, 0)
end)
playbutton.MouseButton1Click:Connect(function()
if script.Parent.SpinnerText.Text == "Orange" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Orange
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
if script.Parent.SpinnerText.Text == "Red" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Red
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
if script.Parent.SpinnerText.Text == "Gold" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Gold
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
if script.Parent.SpinnerText.Text == "Blue" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Blue
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
if script.Parent.SpinnerText.Text == "Green" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Green
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
if script.Parent.SpinnerText.Text == "Nothing" then
local orev = game.ReplicatedStorage.Events.Setup.Colours.Nothing
orev:FireServer()
script.Parent.Parent.Characters:Destroy()
script.Parent:Destroy()
end
end)