Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My keyboard input script isnt working?

Asked by 7 years ago

I'm trying to make a script where when you press E the GUI frame moves to a different position, but its not working( the original position is 220,50)

local GUI = game.StarterGui.ScreenGui1.HIghlightGUI
function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
        GUI.Position = UDim2.new(340,50)
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

2 answers

Log in to vote
0
Answered by 7 years ago

The problem might be your spelling, but his may not be the case. Make sure the Gui is called "HI"ghlightGUI and not "Hi"ghlightGui.

Ad
Log in to vote
0
Answered by 7 years ago

UDim2.new expects 4 arguments, X scale, X offset, Y scale, and Y offset. What I think you wanted is

UDim2.new(0, 340, 0, 50)

Also, you should be editing the player's PlayerGui, instead of the StarterGui.

Hope this helps!

Answer this question