How do I change this script?

I’m trying to edit my script to where when the door opens, (Proximity prompt is finished) the player can no longer use the proximity prompt, and the door stays open.
Original script:

local Hinge = script.Parent.Hinge
local opened = false

function Open()
	if opened == false then
		opened = true
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(9), 0))
			script.Parent.ProximityPrompt.Enabled = false
			wait()	
		end
		wait(1)
		opened = false
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-9), 0))
			script.Parent.ProximityPrompt.Enabled = true
			wait()
		end
		end
		end
	
script.Parent.ProximityPrompt.Triggered:Connect(Open)

I’ve tried doing this,

local Hinge = script.Parent.Hinge
local opened = false

function Open()
	if opened == false then
		opened = true
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(9), 0))
			script.Parent.ProximityPrompt.Enabled = false
			wait()	
		end
end
script.Parent.ProximityPrompt.Triggered:Connect(Open)

and this

local Hinge = script.Parent.Hinge
local opened = false

function Open()
	if opened == false then
		opened = true
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-9), 0))
			script.Parent.ProximityPrompt.Enabled = true
			wait()
		end
		end
		end
	
script.Parent.ProximityPrompt.Triggered:Connect(Open)

(Neither work)
just wanted to add im not the best at scripting.

Add a locked Variable and when it’s open turn it to true, and when it’s true disable the ProximityPrompt

1 Like

sorry, terrible at scripting.
how would I add a locked variable?

I’m away from my computer, so this will probably not work but try this:

local Hinge = script.Parent.Hinge
local opened = false
local locked = false

function Open()
	if opened == false and not locked then
		opened = true
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(9), 0))
			script.Parent.ProximityPrompt.Enabled = false
locked = true
			wait()	
		end
		wait(1)
		opened = false
		for i = 1, 10 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-9), 0))
			script.Parent.ProximityPrompt.Enabled = true
			wait()
		end
		end
		end
	
script.Parent.ProximityPrompt.Triggered:Connect(Open)
1 Like

The script does work, however, once the proximity prompt is activated, and the door is opened completely, I want it to stay in that position, and not close.
(also I want the proximity prompt to be deleted once it has been activated, but I can probably code that)

This should help: TouchDoorTweening.rbxl (54.8 KB)

Do not use this, it’s deprecated. Use this instead:

Oh, tehn simply after it’s opened so

ProximityPrompt:Destroy()

Also sorry if I don’t say this before, I misunderstood :sweat_smile:

Its fine! Edited my script using this, didnt realize previously it would fix it. Thanks!

1 Like

You’re welcome, if you need me anytime I’m here!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.