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 » Scripting Helpers
Home Search
 

Keydown for arrow?

Previous Thread :: Next Thread 
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 05:37 PM
Hey, I planned on making a first person rpg game and wanted it to be so that if you walk backwords your walkspeed is slowed down. So I was going to just have it when you press "s" your walkspeed changes. Anyway, it occured to me that not everyone uses w,a,s,d to move...so I was wondering if it is possible to name the arrow key for down?
Report Abuse
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 05:42 PM
If not, is there perhaps another way to detect that a player is walking backwards? 0.o
Report Abuse
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 05:56 PM
I'm guessing no then? If so is there a way to MAKE someone use w,a,s,d?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Dec 2011 06:05 PM
I don't think there is a way.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Dec 2011 06:06 PM
However, I think there IS a way to detect if an arrow key is being pressed, so just freeze them if they're pressing an arrow key.
Report Abuse
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 06:19 PM
Yea, but my problem is I don't know what I would say for the arrow key. Is there a specific Rbx.Lua function that has been built in for it?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Dec 2011 06:21 PM
I'm not sure...I'll have to experiment later.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
05 Dec 2011 06:21 PM
blockoo, what about key.byte()?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
05 Dec 2011 06:22 PM
The problem is that I don't know if there's an ASCII code for arrow keys.
Report Abuse
Grove537 is not online. Grove537
Joined: 05 Feb 2010
Total Posts: 3478
05 Dec 2011 06:23 PM
This probably won't work at all, but it's worth a try :P
If you set someone's walkspeed to a negative integer they go backwards, so if they are going backwards their walkspeed might be negative. So, if there walkspeed is less than 0 then the script makes it slower or something like that :P
Probably won't work I just wanted to see x3
I'm sorta new :3

~The greatest free model is your mind~
Report Abuse
textmasterthe9th is not online. textmasterthe9th
Joined: 03 Oct 2008
Total Posts: 752
05 Dec 2011 06:25 PM
or for a fps you could use W,A,S,D and just use W key for walking backwards.
Report Abuse
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 06:44 PM
I wonder if it is registered simply as: Up,Down, Left, Right...?
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
05 Dec 2011 06:49 PM
Arrow keys are alt+017, alt+018, alt+019, and alt+020. It will show up as DC1, DC2, DC3, and DC4 respectively. Arrow keys are called "Device Control" keys. I know these "untypable" characters can be typed in studio, but I'm not sure if they actually work or if you have to use string.byte().


----------
    ~ pwendu46, the unicorn ~
Report Abuse
dynCysgodol is not online. dynCysgodol
Joined: 17 Oct 2011
Total Posts: 185
05 Dec 2011 07:00 PM
I don't believe there is a name for down arrow key, but not many people use arrow keys when on a war game because most people are right handed on mouse, so it probably wont even matter.
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
05 Dec 2011 07:01 PM
ArrowKeyUp
ArrowKeyLeft
ArrowKeyRight
ArrowKeyDown

## don't judge me ##
Report Abuse
Vampire32100 is not online. Vampire32100
Joined: 13 Dec 2008
Total Posts: 1058
05 Dec 2011 09:03 PM
I know I'm probably making some fatal mistake here -.- But for the life of me, I can't figure it out? Does it need to be in a tool? I would prefer it not be.

humans = game.Players:findFirstChild("Humanoid")

function e(mouse)
mouse.KeyDown:connect(function(key)
key = string.lower(key)
if key == "s" or
if key == "ArrowKeyDown" then
if (humans ~=nil) then
humans.WalkSpeed = 10
if key == "w" or
if key == "ArrowKeyUp" then
humans.WalkSpeed = 16

end
end)
end
end
end
end
end
script.Parent.Equipped:connect(e)
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
05 Dec 2011 09:22 PM
Byte codes:

17, 18, 19, and 20 are the byte numbers for arrow keys:

if (key:byte() == 17) then
elseif (key:byte() == 18) then
elseif (key:byte() == 19) then
elseif (key:byte() == 20) then
end


I don't remember which arrow key goes with which number though, sorry. I think it is Up, Down, Left, Right, in descending order in that code.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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