Hey there, thanks for reading this. I have just made a frame that slowly fades in when you press another button, but the button is spam able which means that players can spam the button and make it glitch, another thing I don’t know how to do is making the fade in go faster. Thanks for helping.
local plrService = game:GetService("Players")
local FadeBlock = plrService.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("MenuGUI"):WaitForChild("Block")
function Clicked()
wait(0.2)
FadeBlock.Visible = true
for i = 1, 0, -0.02 do
FadeBlock.BackgroundTransparency = i
wait(0.05)
FadeBlock.BackgroundTransparency = 0
end
end
script.Parent.MouseButton1Click:Connect(Clicked)
local plrService = game:GetService("Players")
local FadeBlock = plrService.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("MenuGUI"):WaitForChild("Block")
local debounce=false
function Clicked()
if debounce==false then
debounce=true
wait(0.2)
FadeBlock.Visible = true
for i = 1, 0, -0.02 do
FadeBlock.BackgroundTransparency = i
wait(0.05)
FadeBlock.BackgroundTransparency = 0
end
end
debounce=false
end
script.Parent.MouseButton1Click:Connect(Clicked)
Basically you just need to add a debounce so its not gonna be spammable and instead of using a for loop you could just use tween service instead to make it transparent
local plrService = game:GetService("Players")
local FadeBlock = plrService.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("MenuGUI"):WaitForChild("Block")
local TweenService = game:GetService("TweenService")
local Info = Tweeinfo.new(Number of how long it will take to play,Enum.EasingStyle.Linear,Enum.EasingDirection.In)
local Goal = {BackgroundTransparency = 1}
local Goal2 = {BackgroundTransparency = 0}
local Debounce = false
function Clicked()
if Debounce == false then
Debounce = true
wait(0.2)
FadeBlock.Visible = true
Local tween1 = TweenService:Create(FadeBlock,Info,Goal1)
Local tween2 = TweenService:Create(FadeBlock,Info,Goal2)
tween1:Play()
tween1.Completed:Wait(time before 2nd tween plays)
tween2:Play()
tween2.Completed:Connect(function()
Debounce = false
end)
end
script.Parent.MouseButton1Click:Connect(Clicked)
That is my bad, sorry. I put the debounce=false on the wrong spot… Here is the updated script:
local plrService = game:GetService("Players")
local FadeBlock = plrService.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("MenuGUI"):WaitForChild("Block")
local debounce=false
function Clicked()
if debounce==false then
debounce=true
wait(0.2)
FadeBlock.Visible = true
for i = 1, 0, -0.02 do
FadeBlock.BackgroundTransparency = i
wait(0.05)
FadeBlock.BackgroundTransparency = 0
end
debounce=false
end
end
script.Parent.MouseButton1Click:Connect(Clicked)