Userinputservice help

Right so instead of using mousebutton1click how do I use userinputservices keycodes to connect a function?

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(Input,IsChatting)
   if not IsChatting and Input.UserInputType == Enum.UserInputType.MouseButton1 then
      print("Detected Mouse Click using UIS")
   end
end)

Why do you want to do this instead of MouseButton1Click?

Well, i prefer it and it’s easier then making a custom proximity prompt

Did you mean this?

Button.InputBegan:Connect(function(input)
   if input.UserInputType == Enum.UserInputType.MouseButton1 then
      --do something
   end
end)

Let me explain just say I have a billboard gui which consists of a button when I’m within the proximity of that button and press a keycode It’d carry out a function basically a proximity prompt

You can detect when player presses a certain key like this:

local Key = Enum.KeyCode.E
UserInputService.InputBegan:Connect(function(input, gp)
   if gp then return end
   if input.KeyCode ~= Key then return end

   -- do something
end)

Adding on to what @NeoBuilds said, after you check for the input, let’s say if you pressed E, check if their in range of the “proximity prompt” if so, so what you want

Bruh you can do the same prox prompts no need for UIS.

yeah i am aware but proximity prompts are tedious when it comes to making custom 1s

What are you struggling with. I will be very happy to help you. GUI? Events?

I’m just wondering about how i’d be able to detect if someone with a GUI which is enabled is within a certain proximity of a player

Ok

Grab a Prox Prompt and parent it to a child and then make a script in it

local Prompt = script.Parent

Prompt.Triggered:Connect(function()
print("The Prompt was Triggered!")
end)

that’s no where near what i asked for

Maybe something like this:

local Key = Enum.KeyCode.E
local player = game.Players.LocalPlayer
UserInputService.InputBegan:Connect(function(input, gp)
    if gp then return end
    if input.KeyCode ~= Key then return end
    local char = player.Character or player.CharacterAdded:Wait()
    if not (char.HumanoidRootPart.Position - thePartThePromptIsIn.Position).Magnitude <= dist then return end

   -- do something
end)