Making a door use keydown if player presses e

So I have a question on how I would script a door uses a few parts 4 trim pieces and glass and a union doorknob and I want to use values and make it so it opens the door if player presses e and also plays a sound how would I script all of this it’s a (swinging door) Knob is usually on the left side and there’s a decal in the glass as well how would I go about this and scripting wise

2 Likes

You can use ContextActionService in a LocalScript, detect when the player is near/looking at a door, and bind the action to fire a remote event to open it.

3 Likes

How would I go about that I’ve never really seen this. But heard and seen pictures of this

Did you find any YouTube tutorials about this?

I haven’t watched the video myself but there is a “Keybind Door” tutorial video for Roblox on Youtube available.

It’s pretty positively rated so it might be able to help you.

Otherwise, I’d check the Roblox wiki for keyboard input tutorials and such

No I found one but it uses one part when I need a couple parts in that door

Try welding these parts in model or maybe make one basic part and just place other parts in that basic part.

1 Like

The group I’m referring to in new haven county as I wanna do a door thing like there’s and they used multiple parts so I don’t think it will work I was told bu there ex Dev they use values in a config folder and have a script and door is multiple parts also has a group I’d they must be in to open it, plays a sound as well, he never got back told me there scripts but.basic functinoality

Try it.

As Awesomely said, you can use Welds to accomplish this pretty easily.

There are several Scripts that weld a model together for you, such as Quenty’s qPerfectionWeld.

1 Like

You can use this to bind actions (there is a complementary UnbindAction).

You can check if the player is near a door by checking every Heartbeat if their torso is within a reasonable magnitude of a door (you can use CollectionService to create/get a list of doors).

2 Likes

The group I’m referring to in new haven county as I wanna do a door thing like there’s and they used multiple parts so I don’t think it will work I was told bu there ex Dev they use values in a config folder and have a script and door is multiple parts also has a group I’d they must be in to open it, plays a sound as well, he never got back told me there scripts but.basic functinoality(from above)

You just copied and pasted your last message…?

4 Likes

Have you tried doing any exploration yourself? Seems like you’re asking for free code without doing any work on your own end. It’s not productive for anyone if we give you code you don’t understand or can’t use, nor if you don’t do your own research firsthand.

3 Likes

I do know the basics I watched one online but it was used with one object I am not home so I can’t do coding right nkw

The development support is not a substitute for the development process, it is a place to get help during it. That being said I can give an example on context action service.

local function actionToBind(_, inputState, inputObject)
    print("Input state:", inputState.Name, "Input object:", inputObject.UserInputType.Name)
end

game:GetService("ContextActionService"):BindAction(
    "action name", -- name of action
    actionToBind, -- bound function
    false, -- create mobile touch button
    Enum.KeyCode.E -- input type(s) to bind
)
2 Likes

will do it and test it and susbstitute some code and play around with it tonight