So, I'm trying to make a Gui Game, but the "onkeydown" isn't working, 38 means ^. Thats the key number. But it's not working, any help?
function onkeyDown(key) if key == 38 then script.Parent.Position.Z = 200 end end
or
function onkeyDown(key) if key == 38 then script.Parent.Position = {0.5, -50},{0, 200} end end
Thanks!
You need to use string.byte to use the number of the key.
function onkeyDown(key) if key:byte() == 38 then script.Parent.Position = UDim2.new(0.5, -50, 0, 200); end end
function onkeyDown(key) if tonumber(string.byte(key)) == 38 then script.Parent.Position = UDim2.new(.5,-50,0,200) end end PATHHERE.MouseButton1Click:connect(onkeyDown) --PATHHERE = path to the gui button
should work, idk if tonumber is required :P
from what I see in the comments you need to do this
function onkeyDown(key) if key:byte() == "38" then script.Parent.Position = UDim2.new(0.5, -50, 0, 200); end end
if the key part works then this will
function onkeyDown(key) if key == 38 then script.Parent.Position = UDim2.new(.5,-50,0,200) end end
Few mistakes. One:
function onkeyDown(key) if key == "38" then -- Quotation Marks script.Parent.Position = {0.5, -50},{0, 200} end end
For two: you might want to pick another letter instead of "^" because you have to hold shift.
function onkeyDown(key) if key == "Letter goes here" then -- Quotation Marks and any letter you want. script.Parent.Position = {0.5, -50},{0, 200} end end
Though, I'm not highly 100% sure it will work.