I have looked everywhere and tried a lot of different things to attempt to add a debounce to this script:
local ScannerButton = game.Workspace.ScanButton.ClickDetector
local TweenService = game:GetService("TweenService")
local ScannerPart = game.Workspace.ScannerPart
local enabled = true
ScannerButton.MouseClick:Connect(function()
local info = TweenInfo.new(
2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
true,
0
)
local Goals = {
Position = Vector3.new(66.8, -0.7, -35.1),
}
local PartTween = TweenService:Create(ScannerPart, info, Goals)
PartTween:Play()
enabled = true
ScannerPart.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player ~= nil then
for i,v in pairs(player.Backpack:GetChildren()) do
if v:WaitForChild("Contraband").Value == true then
game.Workspace.ScannerDisplayPart.ScannerScreen.ScannerResults.Text = "ARMED"
else if v:WaitForChild("Contraband").Value == false then
game.Workspace.ScannerDisplayPart.ScannerScreen.ScannerResults.Text = "CLEAN"
end
end
end
end
end)
end)
Could someone please help; I’m very new to debounce and I have tried so much times to add a debounce.