Hit a roadblock on debouncing

Hello, good day. I’ve been working on a button for a few weeks now or months (I don’t really know anymore). And, i’m stuck with debouncing. I don’t know what to do because i’m no scripter. The original code is from Push The Button and i made added little changes with it. I will really appreciate your help.

-- Services
local TweenService = game:GetService("TweenService")

 -- Variables
local Obstacle = game.Workspace.Game.Obstacles.ObstaclePartA

local ObstacleTweenInfo = TweenInfo.new(
	30,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Functions = {}
local touched = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if touched == false then 
touched = true

-- Execute
function Functions:Execute()
	print("Button with the ID" .. script.Parent.Name .."was pressed")
	local ObstacleTween = TweenService:Create(Obstacle, ObstacleTweenInfo, {Transparency = 0, Position = Vector3.new(-86.45, -4.5, 75)})
				ObstacleTween:Play()
				wait(10)
touched = false

end

end
end

-- Return
return Functions

And this is the error i get:
“Expected ‘end’ (to close ‘function’ at line 18), got < eof >; did you forget to close ‘then’ at line 20?”

There are no end in this if then statements

Or are there? Pls intend your code correctly to avoid this problems

1 Like

You forgot a end) to close the touched event.

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if touched == false then 
touched = true

-- Execute
function Functions:Execute()
	print("Button with the ID" .. script.Parent.Name .."was pressed")
	local ObstacleTween = TweenService:Create(Obstacle, ObstacleTweenInfo, {Transparency = 0, Position = Vector3.new(-86.45, -4.5, 75)})
				ObstacleTween:Play()
				wait(10)
touched = false

end

end
end
end)
1 Like

Oh, wow it worked… Thank you! But, how do i make the touched event a valid member of the script? I’m really sorry if i’m causing you any trouble, i really don’t know how to script…