|
| 27 May 2015 08:54 AM |
I need a run a function whenever the chatbutton is pressed (key "/") How do I do this? |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 08:56 AM |
KeyDown:connect(function(key) if key == "/"then --Stuffz here end end)
How I would do it. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 27 May 2015 08:59 AM |
| http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 08:59 AM |
I remember you made a post similar to this before...
UserInputService is needed, by the way.
@Script
You're outdated bro. KeyDown is deprecated.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:05 AM |
| I know it's deprecated, but i'm always using deprecated things so I have not a care in the world :) |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:06 AM |
If ChiefDelta was here - he would say something like this: 'If you use KeyDown you're a bad scripter'. :P
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:07 AM |
| It'd be a battle it ChiefDelta were here lol. |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:07 AM |
Yeah I'm not sure how I feel about using keydown. Feels like it's only got work on 20% of the computers.
I can use userinputservice; but the keycode for 7 and / is the same so I'm abit confused.
Also, previous post was about checking wether chatbar is selected or not, it's not the same.
|
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:07 AM |
I don't even know how to use UserInputService. The wiki doesn't even give a clear example!
|
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:11 AM |
Slash and 7 aren't the same, Slash is 47; 7 is 55.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:20 AM |
local UIS = game:GetService("UserInputService") local function ReceiveInput(Input) local IS = Input.UserInputState local IT = Input.UserInputType if IT == Enum.UserInputType.Keyboard then local code = Input.KeyCode if code == Enum.KeyCode.Slash then script.Parent:CaptureFocus() end end end
UIS.InputBegan:connect(ReceiveInput) UIS.InputEnded:connect(ReceiveInput) UIS.InputChanged:connect(ReceiveInput)
Doesn't react to slash :/ |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:33 AM |
Use KeyUp It works for I and O so it might also work for / |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 09:33 AM |
This worked fine for me.
local UIS = game:GetService("UserInputService") local TextBox = script.Parent
UIS.InputBegan:connect(function(Input) if(Input.KeyCode == Enum.KeyCode.Slash)then TextBox:CaptureFocus() end end) |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:34 AM |
It seems like Enum.KeyCode.Slash is the - button for me. How do coregui handle the slash event? |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:36 AM |
| Slash doesn't work in studio, test it in a live game. Also, don't take input for Changed, Began, and Ended or else it will fire probably like 5 times. Use Began if you want it when it is first pressed, Ended if you want it when it is released. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 May 2015 11:36 AM |
| Go find out; it's on Github |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:40 AM |
GuiService:AddSpecialKey(Enum.SpecialKey.ChatHotkey) this.SpecialKeyPressedConn = GuiService.SpecialKeyPressed:connect(function(key) if key == Enum.SpecialKey.ChatHotkey then this:FocusChatBar() end end) |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:10 PM |
Thanks.
Unfortunatly GuiService is only allowed to be run by roblox core scripts. |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:18 PM |
| Are you saying you made a whole game of R2D without knowing ANYTHING about UIS? |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:28 PM |
I guess he is using KeyDown all the way down there :P
One day ROBLOX will completely remove the deprecated events and everything will break. |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:38 PM |
| I have a hard time believing someone who can create working zombies has never used UIS. |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:38 PM |
| Roblox will never remove deprecated stuff |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:39 PM |
| When they remove deprecated events, ALL of my scripts, except possibly my newest one, will break and be beyond repair. |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:39 PM |
| So will many games I know of. For example Mad Paintball uses KeyDown. |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 05:46 PM |
| theres an example in my models |
|
|
| Report Abuse |
|
|