It is supposed to tween a GUI onscreen when you press 'h'
g = script.Parent f = g.Frame p = game.Players.LocalPlayer m = p.GetMouse() function help() m.KeyDown:connect(function(key) if Key:byte() == 104 then f:TweenPosition(UDim2.new(0,100,0,250)) end end) end coroutine.resume(couroutine.create(help))
On line 9,
Key is nil, while
key is not.
Change Line 9 to:
if key == "h" then. I personally prefer to use characters themselves in those cases, as it is more readable.
There are a few problems here.
p = game.Players.LocalPlayer m = p.GetMouse()
GetMouse is a Method, therefore it needs to be called with a
m.KeyDown:connect(function(key) if Key:byte() == 104 then
You define the variable as
keybut then used it as
Key. Just change one or the other to match.
You also are randomly calling this as a coroutine? Why is that?
To add to Jobro's answer, there's no reason to set up your event inside of a function running in another thread. Events will run asynchronously. Also, remember that you can only use
GetMouse in a LocalScript.
In your code, the argument given to the function is stored in
key. However, you use the variable
Key in your if statement. Also, instead of converting
key to a number, you can simply check if that variable
key is equal to the string