You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I would like to be able to start a function if the player is physically touching the part and at the same time if he’s clicking a keyboard key, like “E”.
What is the issue? Include screenshots / videos if possible!
Idk how to write it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Didn’t found anything
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Character = Players.LocalPlayer.Character
local function IsTouchingPart(Part)
local OverlapParam = OverlapParams.new()
OverlapParam.FilterType = Enum.RaycastFilterType.Whitelist
OverlapParam.FilterDescendantsInstances = Character:GetDescendants()
return #workspace:GetPartsInPart(Part, OverlapParam) > 0
end
if UserInputService:IsKeyDown(Enum.KeyCode.E) and IsTouchingPart(workspace.Part) then
print("e and touching part")
end