Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i use tick() to check how long a key was held? [closed]

Asked by 4 years ago

so basically i want to make a ability where the more u hold it the stronger and bigger it gets when it hits 4 sec or somehting it will fire the ability

thx for the help :D

0
This is not a request site. First, try scripting it, if it doesn't work, you can get help from here BestCreativeBoy 1395 — 4y

Closed as Not Constructive by BestCreativeBoy, imKirda, and DeceptiveCaster

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Here is the code

Sorry for my english hope you understand me

01local UserInput = game:GetService("UserInputService")
02local Before = tick() --Current tick time
03local Pressed = false --If key was pressed before
04 
05UserInput.InputBegan:Connect(function(Key,Processed)
06    if not(Processed)then
07        if(Key.KeyCode == Enum.KeyCode.B)then --Key, Enum.KeyCode[Key]
08            Before = tick() --Current tick time
09            Pressed = true --Key was pressed
10            print("Key was pressed")
11        end
12    end
13end)
14UserInput.InputEnded:Connect(function(Key)
15    if(Key.KeyCode == Enum.KeyCode.B)then --Key, the same as above
View all 22 lines...
Ad