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
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 20341 |
|
| |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 677 |
|
|
| 02 Jun 2015 09:33 PM |
Yeah do localscript
=volty= |
|
|
| Report Abuse |
|
|
xlaser23
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 20341 |
|
|
| 03 Jun 2015 08:58 PM |
| e.e... i didnt want userinputservice .-. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 08:59 PM |
| Then use ContextActionService. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 09:00 PM |
@voItages BindActionToInputTypes is deprecated; use BindAction instead. |
|
|
| Report Abuse |
|
|
xlaser23
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 20341 |
|
| |
|
|
| 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
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 20341 |
|
|
| 03 Jun 2015 09:09 PM |
| I gotta understand it first doe <.< |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 09:10 PM |
| What part do you not understand? |
|
|
| Report Abuse |
|
|
xlaser23
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 20341 |
|
|
| 03 Jun 2015 09:11 PM |
| Enum, IN reading it to understand it doe |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|