So I want to make a script that finds out the time in between clicks.
For example:
Player clicks
Player clicks again
Prints the time before he clicked the second time
I really need help! So thank you in advance.
Ok here you go, this should print the time difference between each click (currenttime - lasttime = difference).
local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local lasttime = tick() mouse.Button1Down:Connect(function() local t0 = tick() local timediff = t0 - lasttime -- pro maths here print("Last click was " .. timediff .. " seconds ago!") lasttime = t0 -- The other answers didn't update the last time :( end)
(an upvote would be appreciated)
Add a Debounce.
Local db = false If not db then db = true --Do something wait (1) -- How long the duration of the click again db = true
Pretend this Script is a child of a ClickDetector, and you're changing a part color.
local StartTime = tick() local ClickDetector = script.Parent ClickDetector.MouseClick:Connect(function() workspace.Part.BrickColor = BrickColor.new("Fog") -- example Part print("This took: "..StartTime - tick()) -- you can use math.abs() to get the absolute value i think, not sure dont judge me :( end)
Please accept this answer if this helped!