Posts: 5
Threads: 2
Joined: Aug 2011
Reputation:
0
I'm trying to make a car that drives left when you hit the left button. Every time I run this script, it says "keyDown is not a property, function, or child of Hinge." Can someone please tell me what I'm doing wrong?
function keydown (LeftArrow)
if keydown then script.Parent.Motorspeed = -5.0
end
end
link(script.Parent.keyDown, keydown)
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
KeyDown is only a function of a Tool, and you need to specify which key as a string or byte code. Which is pretty complicated stuff. I might get back to you with a more detailed answer soon
Posts: 5
Threads: 2
Joined: Aug 2011
Reputation:
0
I see. So I'd basically have to make a tool for this to work.
Actually, that would work better, probably.
But is LeftArrow a legitimate command? I wasn't sure what it would be called.
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
It would be something like
[lua]
function keypressed(key)
if key == string.char(019) then
--dostuff
end end
link(script.Parent.KeyDown, keypressed)
[/lua]
But I've had issues with byte codes not working...
Personally, I think that using WASD would be easier than trying to use the arrow keys.
Posts: 5
Threads: 2
Joined: Aug 2011
Reputation:
0
Yeah, that makes sense. Thanks for the code!