So, I have this part of a local script:
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local toggle = false
local door = workspace.Door
mouse.KeyDown:connect(function(key)
if key == string.lower("r") then
if toggle == false then
toggle = true
door.CanCollide = false
else
toggle = false
door.CanCollide = true
end
end
end)
So, how do I make it so that the .KeyDown event (or UserInputService.InputBegan) only available when you're near a part?

3 comments
You could put a click detector in the door so when the mouse is hovering it sets the toggle to true, and when the hover leaves it sets the toggle to false. Depending on if your using filtering enabled which I recommend you will have to use remote events to trigger the local script
If you are still confused I can help you out further.
Alternatively you could have an invisible part in the area you want the player to be able to open the door and detect if player is touching it and then turn toggle on