generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Key Down

Previous Thread :: Next Thread 
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
02 Jun 2015 08:54 PM
Well, making a gui pop up on a keypressed event

Does it go like this

if key =="g"then...?

--code

end
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
02 Jun 2015 09:07 PM
Rip help
Report Abuse
ShadowAley is not online. ShadowAley
Joined: 23 Jun 2010
Total Posts: 4823
02 Jun 2015 09:09 PM
yeah
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
02 Jun 2015 09:14 PM
You should use UIS or CAS

----------UIS--------------
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.G then
print("G was pressed")
end
end
end)

---------CAS--------------

function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print("G was pressed")
end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.G)--Set Key



=volty=
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 Jun 2015 09:16 PM
@voltages how do you define the player who pressed?
like...

if player.Name == "Player" then
print(player.Name.." pressed G")
end
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
02 Jun 2015 09:20 PM
this?

plr = game.Players.LocalPlayer


----------UIS--------------
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.E then
print(plr.Name.." pressed E")
end
end
end)

---------CAS--------------

function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
print(plr.Name.." pressed R")
end
end

game.ContextActionService:BindActionToInputTypes("keyPress", onKeyPress, false, Enum.KeyCode.R)



=volty=
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 Jun 2015 09:27 PM
@volt when I used UIS, it only worked in a server script for me..is it suppose to be a local script?
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
02 Jun 2015 09:33 PM
Yeah do localscript



=volty=
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
03 Jun 2015 08:58 PM
e.e... i didnt want userinputservice .-.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
03 Jun 2015 08:59 PM
Then use ContextActionService.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
03 Jun 2015 09:00 PM
@voItages
BindActionToInputTypes is deprecated; use BindAction instead.
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
03 Jun 2015 09:00 PM
2Advanced4Me

But I'll Try
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
03 Jun 2015 09:01 PM
He posted exactly how to use it. In fact, you could literally just copy those scripts.
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
03 Jun 2015 09:09 PM
I gotta understand it first doe <.<
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
03 Jun 2015 09:10 PM
What part do you not understand?
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
03 Jun 2015 09:11 PM
Enum, IN reading it to understand it doe
Report Abuse
VineyardVine is not online. VineyardVine
Joined: 20 Nov 2010
Total Posts: 904
03 Jun 2015 09:15 PM
Here is the old fashioned Method

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


mouse.KeyDown:connect(function(key)
if key == "g" then
game.Workspace.Gui:clone().Parent = player.Playergui
end
end)
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
03 Jun 2015 09:17 PM
Enums are basically just a way to map names to values. For example, your computer doesn't actually specify a specific name for each key on your keyboard. Instead, it just uses a number to represent the key. But it can be quite difficult to remember the number, so it is much simpler to just remember the name of the key, then your computer can use the enum to get the value of the key that it understands. You can find the value of an Enum by doing Enum.Value, or you can get an Enums name by doing Enum.Name.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image