So I'm trying to find out how to do a keydown script where when you press Q your wep pulls out base off an animation kind of like sbo weps, and then when you click it swings doing dmg to people. Anyone can tell me how to do it?
here is a simple code in how to detect the players mouse, first you need to get the mouse using the :GetMouse()
function.
Player = script.Parent.Parent --Finding You / Player mouse = Player:GetMouse() -- Getting the players mouse
then we will need to create a funtion to dectect the key press/lowering in this case
function onKeyDown(key) key = key:lower() end mouse.KeyDown:connect (onKeyDown)
finally we define the key we want to lower into the function
if key == "q" then --"q" Is the Key that will be pressed for this action to work
So are final code would be:
Player = script.Parent.Parent --Finding You / Player mouse = Player:GetMouse() function onKeyDown(key) key = key:lower() if key == "q" then --"q" Is the Key that will be pressed for this action to work end end mouse.KeyDown:connect (onKeyDown)
This is just a simple code to set you in the right direction, not the full code