i want to make a script in my game where when a person presses the key he does like a punch or a kick that does some damage but none of the key detecters i found work so can u guys help me?
✓ ANSWER ACCEPTED
How to set a script that detects if a key is pressed?
1 answer
✓ Accepted answer
This should help you out. (PUT THIS IN A LOCAL SCRIPT)
local plr = game.Players.LocalPlayer --Gets player
local mouse = plr:GetMouse() --Gets mouse
mouse.KeyDown:Connect(function(key)
if key == "Q" then --You can change this letter to any letter you want.
--Your script goes here, if you are not sure how to make an animation or use one, ask someone else or make a new post. But first, try googling it and all that.
end
end)
3 comments
0
KeyDown is deprecated, It's encourged to instead use UserInputService.
0
i tried that script before doesnt work
0
ohhh i figured out the problem i put the script in the wrong area XD i was supposed to put in starter player scripts not workspace xd that why never worked oof i must sound stupid now
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I only can give you the part that detects the key but I don't know how to make the animation