Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My keyboard input script isnt working?

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

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.

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.