So I was creating a parkour script, and I wanted to play a panting audio when the player has held down LeftShift or RightShift for around 5 seconds.
I use UserInputService, and I don't know many forms of Input functions. The nearest I could find was IsKeyDown.
Here's my script, if you would like to polish it.
local UIS = game:GetService("UserInputService")
local RunningSound = 'rbxassetid://4518544160'
local WalkingSound = 'rbxassetid://156659098'
local running = script.Parent.HumanoidRootPart:WaitForChild("Running")
running.SoundId = WalkingSound
running.Pitch = 1.5
UIS.InputBegan:Connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.LeftShift or keyCode.keyCode == Enum.KeyCode.RightShift then
running.SoundId = RunningSound
end
end)
Now, I'm not asking for scripts or anything. I just want to learn a method of detecting when the player's key is being held down.
Help please!

1 comment
Tysm! This helped me SOOOO much!