Its a button that opens your stats. you click it and it'll do a little effect and show you them, and it undo's it when you click it again. All works well but a friend pointed out that if you spam click the button fast enough you can glitch out the part that changes your FOV and it breaks.
Error:
18:52:10.163 - FieldOfView set out of range, should be between 1.000000 and 120.000000, setting to 120.000000 (x3962) And that Large number at the end just increases very fast.
Lines altering FOV are 16 and 27.
Here is the script:
local but = script.Parent
local open = false
but.MouseButton1Click:connect(function()
but.TextColor3 = Color3.new(0, 0, 0)
wait(0.1)
but.TextColor3 = Color3.new(255, 255, 255)
but.Click:Play()
if open == false then
but.Parent.Back.Visible = true
but.Woosh:Play()
repeat
game.Lighting.Blur.Size = game.Lighting.Blur.Size + 1
game.Lighting.CC.Brightness = game.Lighting.CC.Brightness + 0.01
game.Lighting.CC.Contrast = game.Lighting.CC.Contrast + 0.1
workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + 0.8
wait()
until game.Lighting.Blur.Size == 19
open = true
elseif open == true then
but.Parent.Back.Visible = false
but.Woosh:Play()
repeat
game.Lighting.Blur.Size = game.Lighting.Blur.Size - 1
game.Lighting.CC.Brightness = game.Lighting.CC.Brightness - 0.01
game.Lighting.CC.Contrast = game.Lighting.CC.Contrast - 0.1
workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView - 0.8
wait()
until game.Lighting.Blur.Size == 0
open = false
end
end)
i'm not quite sure why spam clicking causes this, is there a way to stop this? Any help is appreciated

5 comments
It's the user's fault if they spam clicked it.
Yes I am aware, simply resetting will fix it, just wondering if there is any way to stop it? Something that could help in the future? Other than that its no biggie
http://wiki.roblox.com/index.php?title=Debounce
Also, use Color3.fromRGB
Yeah I would agree with hiimgoodpack. Learn how to use debounce as a bool variable