Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a movable door with script?

Asked by 9 years ago

I dont want that screw thing that makes the door move when my robloxian pushes it. So I want a script that makes it move by using a button (e.g press f and it opens). So please does any one know how to make it? Still new being a scripter.

1 answer

Log in to vote
0
Answered by 9 years ago

UserInputService is used when you want a script to pick up input from the keyboard or mouse. There's an event called InputBegan that is triggered when the game receives an input. It has a parameter called input, which you can use to check what key was pressed.

function onKeyPress(input)
    if input.KeyCode == Enum.KeyCode.F then --If the key pressed was F then
        --Insert code here
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Here are some links that explain what KeyCode and Enum is. The rest of the code that moves the door can vary depending on how you want it to move. Just comment how you want it to move and I can help you with it.

0
Thanks! Bloodyskelly 5 — 9y
0
I want it to move sideways. Like a normal door does. Bloodyskelly 5 — 9y
0
No prob. Is your door a model or a single brick? Moving models is a bit more complicated than normal bricks, but it's nothing we can't do. IcyArticunoX 355 — 9y
Ad

Answer this question