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)
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)
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
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)
stuff in StarterGui dosen’t change.
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")
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)
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”
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)
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).