Welcome back Dev Forum, I am back to ask a question that I don’t think anyone has had to ask yet. But I am curious on which is more accurate between timing.
Using a click detector.
Using UI’s and TextButtons.
Using UserInputService and then detecting whether the player has hit the object or missed.
The timings here are crucial as it would affect the score the player receives.
Thank you, I do not currently have time to produce these tests myself, and I also think that this information may be useful for some people. Please may you include how you did these benchmarks so that I can also replicate them, whilst also letting other people view how this was solved.
No problem! Alright, after testing it seems that to detect clicking UserInputService is the winner.
I actually don’t know how/if you can benchmark clicks. So what I did is I added a print in each script for each method and saw which printed first. I clicked multiple times (and even ran an autoclicker for a little) and every time the print for UIS printed first. Code:
(UIS, Local Script StarterPlayerScripts)
local UIS = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local Target = mouse.Target
print("Clicked U", Target)
end
end)
(Script inside Click Detector)
local Target = script.Parent.Parent
script.Parent.MouseClick:Connect(function()
print("Clicked C", Target)
end)
(Local Script In Text Button)
local mouse = game.Players.LocalPlayer:GetMouse()
script.Parent.MouseButton1Click:Connect(function()
local Target = mouse.Target
print("Clicked B", Target)
end)
The UserInputService can run along side both at once. So I first checked if the UIS is faster than clicking the part, then check to see if it’s faster than clicking the text label. I don’t think theres anyway to compare the speeds of the text button VS the Click Detector (because their meant for dif things)