You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am trying to make a quick and heavy atk system based on how hard/long someone clicks how do i do smthg like this?
What is the issue? Include screenshots / videos if possible!
I have no idea as to how i get how hard/long someone clicks without being heavy on performance
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried googling and searching on devforum
if possible i wanna avoid using loops to see how hard they click mouse
Since you want to avoid using loops, your only option is detecting how long a user has held the mouse for after they let go of it. Here is how you would go on about it:
local UserInputService = game:GetService("UserInputService")
local holdTime
local function round(num) -- Rounds the number to 2 decimal places, makes the number more readable.
num *= 100
num = math.floor(num)
return num / 100
end
UserInputService.InputBegan:Connect(function(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
holdTime = tick()
end
end)
UserInputService.InputEnded:Connect(function(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
holdTime = tick() - holdTime
print("You held the mouse for "..round(holdTime).." seconds.")
end
end)