I'm a new developer to roblox and figured it would be a good place to start learning to make games. I was working on my game today and I ran into an issue. I wanted to press 'E' while by a NPC and I got that to work. The only problem was, I have no clue how to make the GUI appear and Dissapear when I press E. This is what I have written,
local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local Npc = game.Workspace.Noob.Head
UIS.InputBegan:connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.E then
if (Npc.Position - HumanoidRootPart.Position).magnitude < 15 then
game.StarterGui.TextF.TextLabel.Visible = 0
wait(3)
game.StarterGui.TextF.TextLabel.Visible = 1
end
end
end)
it comes out with no error. The code to press E still works, but the GUI does not pop up. I have tried setting the values to True or False