Trying to make a custom camera that is moved with the WASD keys
Use the KeyDown Event. You can define WASD using the second parameter.
Syntax: KeyDown (String, key).
Inside a script inside a hopperbin:
1 | function onSelected(mouse) |
2 | function onKeyDown(key) |
3 | print (key) -- That's the key you pressed. |
4 | end |
5 | mouse.KeyDown:connect(onKeyDown) |
6 | end |
7 | script.Parent.Selected:connect(onSelected) |
Hope that helps!
If you were trying to make a custom camera or a 'Probe' as some would say, you could always use Workspace.CurrentCamera.Focus or Workspace.CurrentCamera.CoordinateFrame (focus for in game coordinate frame for nil) But in this case, the one I am giving you is detecting which key is being pressed in the movement category, and if it matches it then it prints which way your going.
01 | s = game.Players.LocalPlayer |
02 | m = s:GetMouse() |
03 | m.KeyDown:connect( function (a) |
04 | if a:lower() = = "a" then |
05 | print 'left' |
06 | elseif a:lower() = = "s" then |
07 | print 'down' |
08 | elseif a:lower() = = "w" then |
09 | print ' up' |
10 | elseif a:lower() = = "d" then |
11 | print 'right' |
12 | end |
13 | end ) |