✓ Accepted answer
##Problem
It helps people out a great amount if the code is tabbed properly, so they may know where all the ends and functions line up. In your script you have a misplaced end for a function that would make it never able to be called on line 21. Secondly, since you set the lastTapTime variable inside the if statement, the script would always say it is less than or equal to one because you check that immediately.
##Solution
All you will have to do is move the end and the variable. What I had done was moved the lastTapTime to the outside of the KeyDown function and set it equal to 0. And I moved the end after the if statement that would check if the key was pressed within a second.
#Final Script
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local lastTapTime = 0
enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled then
return
end
if key == "s" then
local function onTap()
if tick() - lastTapTime < 1 then
print("double Click!")
end
end
onTap()
lastTapTime = tick()
end
end)
##Deprecation
I would advise trying to understand the UserInputService events and functions as KeyDown events are now deprecated in favor of them. Check out the UserInputService's InputBegan event and see if you can convert the script to that. KeyDown should not be used in new works and is right now only kept for compatibility purposes.
######Hopefully this answered your question. If so please hit the accept answer button. If you have any questions feel free to ask them in the comments section below.