Hey, guys so I am having a bit of an issue with ContextActionService. I am trying to make it so that if I hold down a certain key on the keyboard a function keeps running however, when I stop holding it down and let go the function stops working. So now, basically I have tried a lot of this and have worked on it for quiet a long time now. However, I can't grasp as to how I will make this work in the best way that will benefit my game. So the script I have tried to do that with is right here:
local deb = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
function onQ(name,state,action)
if state == Enum.UserInputState.Begin then
while deb == true do
print("ONQ")
wait(.5)
end
elseif state == Enum.UserInputState.End then
deb = false
print("OFFQ")
deb = true
end
end
game.ContextActionService:BindAction("OnQ", onQ, true, Enum.KeyCode.Q)
As you can see above I tried to use a Debounce and I think that's what will help me do it since that's what I used with KeyDown and KeyUp however, this script isn't working exactly how I want it to work.
Any help is appreciated and thank you a lot for reading my question and attempting to help me out.
~~KingLoneCat
