For example, in a Roblox sword if you click once is slashes, if you click twice it lunges. I wanted to know how to do this.
Here's my idea, but will it work, and is there a better way to do it?
tool = script.Parent tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if tool.Clicked then --"Clicked" would be a bool value in the tool print("He double clicked!") tool.Clicked = false elseif not tool.Clicked then print("He only clicked once") tool.Clicked = true wait(0.5) tool.Clicked = false end end) end)
From reading the script, it looks like you're trying to set a BoolValue to true, wait 0.5 seconds and then set it to false. If the bool value is already true, then it means the player clicked within 0.5 seconds, meaning that the player double clicked. I don't see what would error with this, and it would be a perfect way to see if a player double clicked. Although I did find this on the forums, I cannot guarantee that it will work:
local click = tick() mouse.Button1Down:connect(function() if tick() - click < 0.8 then print("double Click!") end click = tick() end)
If you have any questions or need further help, feel free to contact me via commenting on this question. Hope I helped! :)