So recently I started learning how to script and now I have a question.

Right now I know how to make KeyDown events, here is something I made(it is in starter gui):

Players = game.Players.LocalPlayer
mouse = Players:GetMouse()

mouse.KeyDown:connect(function(key)
 if key == "e" then
  print ("u pressed e")
  else 
	print("y u no press e")
 end
end)

I want to make a script that when you walk up to a player a GUI would pop up. If you press "C" it would cuff the player and if you press "Z" it would grab the player and if you walk the player will come with you. How can I do that?

Thanks.

2 comments

0

little bit of advice, don't use keydown, it is deprecated and generally terrible, use the InputBegan event of UserInputService instead