I'm making an ATM machine for a roleplay game I'm working on. I made an "E to interact" and it worked with print so I replaced it with making the ATM Gui visible. It didn't work and there wasn't errors. I tried debugging and it came out positive. My code is a LocalScript:
local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart") local UIS = game:GetService("UserInputService") local Atm = game.Workspace.Atm UIS.InputBegan:Connect(function(keyCode) if keyCode.keyCode == Enum.KeyCode.E then if (Atm.Position - HumanoidRootPart.Position).magnitude <10 then game.StarterGui.ScreenGui.FinnianATM.Visible = true print("Worked") end end end)
Instead of using "Visible = True", I normally Use "Enabled = True" or Enabled = False".
if keyCode.keyCode == Enum.KeyCode.E then
to
if keyCode.keyCode == Enum.KeyCode.e then
probably
local UIS = game:GetService("UserInputService") local ATMHitBox = game:GetService("Workspace"):FindFirstChild("ATM").HitBox local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() wait(0.25) --Wait For The Character To FULLY Load In local HRP = Character:FindFirstChild("HumanoidRootPart") UIS.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.E then if (ATMHitBox.Position - HRP.Position).Magnitude < 10 then --Whatever You Want To Happen print("Works") end end end)
This Also Works As Well