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
Here is the code
Sorry for my english hope you understand me
local UserInput = game:GetService("UserInputService") local Before = tick() --Current tick time local Pressed = false --If key was pressed before UserInput.InputBegan:Connect(function(Key,Processed) if not(Processed)then if(Key.KeyCode == Enum.KeyCode.B)then --Key, Enum.KeyCode[Key] Before = tick() --Current tick time Pressed = true --Key was pressed print("Key was pressed") end end end) UserInput.InputEnded:Connect(function(Key) if(Key.KeyCode == Enum.KeyCode.B)then --Key, the same as above if(Pressed)then --Check if Key was pressed before Pressed = false local HeldTime = tick() - Before --how long a key was held print("Key was helded for: " .. tostring(HeldTime) .. " seconds") end end end)
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?