So I have a gate script, but when I add a debounce it glitches it out even more. How would I add a debounce so, you have to wait 3.5 seconds once you first clicked, before you can click again to make it go down? I already tried adding a wait(3.5) and then making debounce = false, but that just glitched it out. Also, it takes 3.5 seconds for the gate to go fully up or down. Here is the script:
TweenService = game:GetService("TweenService")
local door1 = workspace.MainHolderPart
local clicker = door1.Clicker.ClickDetector
local currentCFrame = workspace.MainHolderPart.CFrame
local currentOrientation = currentCFrame - currentCFrame.p
local tweeningInformation = TweenInfo.new(
3.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local door1Open = {CFrame = CFrame.new(-161.163, 15.155, -125.809) * currentOrientation}
local door1Close = {CFrame = CFrame.new(-161.163, 5.679, -125.809) * currentOrientation}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
local open = false
game.ServerScriptService.RegisterToGateService.OnInvoke = function(a)
clicker.MouseClick:Connect(function(player)
if player.Team == game.Teams["Asylum Command"] then
if not open then
open = true
tween1open:Play()
else
tween1close:Play()
open = false
end
elseif player.Team == game.Teams["Riot Control Unit"] then
if not open then
open = true
tween1open:Play()
else
tween1close:Play()
open = false
end
elseif player.Team == game.Teams["Hospital Administration"] then
if not open then
open = true
tween1open:Play()
else
tween1close:Play()
open = false
end
end
end)
end

1 comment
also use a wait before setting debounce to false again