User input service gui help

is no working :*(

local uis = game:GetService(“UserInputService”)
local frame = game.StarterGui.ScreenGui.Frame

uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.E then
frame.Visible = true
end
end)

2 Likes

Where is this located that might be the problem?

I have this old code that works, and it seems like it’s only “input” without the .KeyCode
image

startergui then screen gui then a frame then a local script

oh yea

local uis = game:GetService(“UserInputService”)
local frame = script.Parent

uis.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.E then
frame.Visible = true
end
end)

1 Like

stuff in StarterGui dosen’t change.

1 Like

I don’t think you can use game:GetService() inside Starter Gui I think you need to get the player gui. Which you can easily get by doing:

local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
1 Like

yes but i dont want the script.Parent i want it to have atleast 2 frames how will i do that?

do it for the two frames

local UIS = game:GetService(“UserInputService”)

local Frame1 = inserthere
local Frame2 = inserthere

UIS.InputBegan:Connect(function(input)
if input == Enum.KeyCode.E then
Frame1.Visible = true
Frame2.Visible = true
end
end)

1 Like

so uhh put local Frame1 = script.Parent.Parent
And frame2 = script.Parent?

Nope.

local Frame1 = script.Parent.Parent.“FrameName”
local Frame2 = script.Parent.Parent.“FrameName”

1 Like

now umm is this how I put it?
a frame inside a frame with the local script or …

local uis = game:GetService("UserInputService")
local frame = script.Parent

uis.InputBegan:Connect(function(input, processed)
	if processed then
		return
	end
	
	if input.KeyCode == Enum.KeyCode.E then
		frame.Visible = true
	end
end)

image

Local script, place it inside the “Frame” instance (I fixed the reference to the frame). Also I’ve added a bit of code which checks whether or not the input (E keypress) was processed by a core component of the game, in other words if the input occurred because the user hit the “E” key while they were typing in chat, then the input is ignored (and the frame isn’t made visible).