Alright, so i made a script for my Menu_Gui, which is you know. The options to Play, Customize Character Looks, and Look at Options to change gameplay experience, etc.
When someone clicks "Play", it brings up a notification i made. That let's them know they will be locked into first person. That once clicking "OK" they will be locked into first person.
This is the script for the button i made. If you're wondering why i did all the transparency, and didn't use a variable, and didn't just use *1. I was bored. I felt like typing each line with transparency change.
function onClicked() game.Players.LocalPlayer.CameraMode = "LockFirstPerson" print("FirstPersonisLocked") script.Parent.Parent.Parent.BackgroundTransparency = 0 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.1 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.2 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.3 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.4 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.5 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.6 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.7 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.8 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 0.9 wait(0.1) script.Parent.Parent.Parent.BackgroundTransparency = 1 wait(0.1) script.Parent.Parent.Parent.Parent:remove() print("everything removed") end script.Parent.MouseButton1Click:connect(onClicked)
Is there a way i could make this be only allowed to be pressed once? Because if i press the button multiple times. It makes this flicker affect, because every time i click it, it's restarting this whole function and script itself. Is there a way i can make it where once you click it, the script works, and then you're not able to keep clicking this button.
Thanks in advanced if you answer!
Let me simplify the code for you
local clicked = false function Clicked() if clicked == false then clicked = true for i=0, 1, .1 do script.Parent.Parent.Parent.BackgroundTransparency = i wait() end script.Parent.Parent.Parent.Parent:remove() print("everything removed") end end script.Parent.MouseButton1Click:connect(Clicked)