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: How to run function when "/" is pressed?

Previous Thread :: Next Thread 
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
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
Scripterity is not online. Scripterity
Joined: 30 Mar 2014
Total Posts: 677
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 is not online. 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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
Scripterity is not online. Scripterity
Joined: 30 Mar 2014
Total Posts: 677
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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
Scripterity is not online. Scripterity
Joined: 30 Mar 2014
Total Posts: 677
27 May 2015 09:07 AM
It'd be a battle it ChiefDelta were here lol.
Report Abuse
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
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
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
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
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
27 May 2015 09:33 AM
Use KeyUp
It works for I and O so it might also work for /
Report Abuse
Sinfesizer is not online. Sinfesizer
Joined: 18 Apr 2015
Total Posts: 46
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
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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 is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
27 May 2015 11:36 AM
Go find out; it's on Github
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
28 May 2015 05:10 PM
Thanks.

Unfortunatly GuiService is only allowed to be run by roblox core scripts.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
28 May 2015 05:18 PM
Are you saying you made a whole game of R2D without knowing ANYTHING about UIS?
Report Abuse
lucas200206 is not online. lucas200206
Joined: 06 Dec 2009
Total Posts: 899
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
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
28 May 2015 05:38 PM
I have a hard time believing someone who can create working zombies has never used UIS.
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
28 May 2015 05:38 PM
Roblox will never remove deprecated stuff
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
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
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
28 May 2015 05:39 PM
So will many games I know of. For example Mad Paintball uses KeyDown.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 05:46 PM
theres an example in my models
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