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

How to make the door script "Press F?"

Please help, just stop viewing it only. You are scripters. Don't be anonymous/unknown.

script.Parent.PrimaryPart = script.Parent.Hinge
hit = false
script.Parent.Parent.Part1.Touched:connect(function()
	if hit == false then
		hit = true
		local i = 0
		while i <= 120 do
			wait()
			script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Hinge.Position) * CFrame.Angles(0, math.rad(i), 0)) --Rotates Door
			i = i + 5
		end
		wait(3)
		local i = 120
		while i >= 0 do
			wait()
			script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Hinge.Position) * CFrame.Angles(0, math.rad(i), 0)) --Rotates Door
			i = i - 5
		end
		hit = false
	end
end)

2 comments

0

If you don't know how to do something, search it on the wiki or use the search bar of this website. That will then link you to questions that are related to what you're after so you can then implement that into your own script

0

Well, the thing is. I get confused a lot with Lua although I'm a medium-scripter. >_>

1 answer

The reason several other scriptures are only viewing it, is because you haven't shown any attempts to do it yourself. This isn't constructive, since you're asking us to create a portion of the script for you. I'll give you a few tips:

I'm supposing you want it when someone Presses F, it opens. To do that, remove line 3, and use the KeyDown event. To use that, you'll have to use game.Players.LocalPlayer:GetMouse() to retrieve the mouse. Note: To use this, it'll need to be a LocalScript within the Player, such as the Player object itself, PlayerGui, or the Backpack.

Once you add in the KeyDown event (Search wiki.roblox.com for it), you'll ned a new debounce. Preferably a value inside of the Hinge itself. A BoolValue that tells if it's open or closed. Also, you'll need another BoolValue to see if another player is already opening/closing it.

That's about as much help as I can give you at this point, so good luck!

2 comments

0

so KeyDown and GetMouse are the same "Body"?

0

You're asking quite late. KeyDown is deprecated, and I'm not sure what you mean by Body

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