Car Driving Problem
#1
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)
Reply
#2
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
Reply
#3
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.
Reply
#4
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.
Reply
#5
Yeah, that makes sense. Thanks for the code!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)