Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to set a script that detects if a key is pressed?

Asked by
TNTIsLyfe 152
4 years ago

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?

0
I only can give you the part that detects the key but I don't know how to make the animation Robloximario952 18 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)



0
KeyDown is deprecated, It's encourged to instead use UserInputService. ScuffedAI 435 — 4y
0
i tried that script before doesnt work TNTIsLyfe 152 — 4y
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 TNTIsLyfe 152 — 4y
Ad

Answer this question