How can I make a UI appear when a player presses E near a part

I’m making a “custom proximity prompt” kind of thing and I want to make it so when you press E when you’re near a part it will make a UI popup.

so basically, if the player is 15 studs away from the scripts parent part, then when they press E, it makes a UI visible.

put this in StarterCharacterScripts:

local Player = game.Players.LocalPlayer
local Part = (refer to your part here)
local uis = game:GetService("UserInputService")
local MenuGui = Player:WaitForChild("PlayerGui"):WaitForChild(put your screengui name here)

uis.InputBegan:Connect(function(input, process)
	if input.KeyCode == Enum.KeyCode.E and not process then
		local char = Player.Character
		if (Part.Position - char:GetPivot().Position).Magnitude < 15 then
			MenuGui.Enabled = not MenuGui.Enabled -- Toggles the menu on and off
		end
	end
end)
3 Likes

didn’t seem to work set the paths and stuff but nothing happens when I pressed e