|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 05 Dec 2011 06:05 PM |
| I don't think there is a way. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 05 Dec 2011 06:21 PM |
| blockoo, what about key.byte()? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 05 Dec 2011 06:44 PM |
| I wonder if it is registered simply as: Up,Down, Left, Right...? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 05 Dec 2011 07:01 PM |
ArrowKeyUp ArrowKeyLeft ArrowKeyRight ArrowKeyDown
## don't judge me ## |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|