Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a movable door with script?

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

✓ Accepted answer

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.

3 comments

0

Thanks!

0

I want it to move sideways. Like a normal door does.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.