Script problem with ProximityPrompt Door

Alright i think im on the right track. it’s opening but then the text disappears.
Current script:

local Proxy = script.Parent.Door.ProximityPrompt
local Hinge = script.Parent.Hinge

local TS = game:GetService(“TweenService”)

local targetOpenCFrame = Hinge.CFrame * CFrame.Angles(0, math.rad(90) ,0)
local defaultCloseCFrame = script.Parent.Door.CFrame

local openTween = TS:Create(script.Parent.Door, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = targetOpenCFrame})
local closeTween = TS:Create(script.Parent.Door, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = defaultCloseCFrame})

local opened = false

Proxy.Triggered:Connect(function()
if opened == false then
opened = true
openTween:Play()
Proxy.ActionText = “Open”
print(“The Door is open”)
elseif opened == true then
opened=false
closeTween:Play()
Proxy.ActionText = “Closed”
print(“The Door is closed”)
end
end)

PS: Sorry i dont know how to embed it

I tested your script and it broke the door after the door was opened. To write a code in lua mod. You may use lua
image

Yeah thats the problem right now also thanks for the tip

I think I’ve found the solution!

Use this script:

lua
local Proxy = script.Parent.Door.ProximityPrompt
local Hinge = script.Parent.Hinge
local opened = false

local debounce = false

Proxy.Triggered:Connect(function()
if opened == false then
opened = true
for i = 1, 22 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(4), 0))
wait()
Proxy.ActionText = “Open”
print(“The Door is opened”)
end
else
opened=false
for i = 1, 22 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame
CFrame.Angles(0, math.rad(-4), 0))
wait()
Proxy.ActionText = “Closed”
print(“The Door is closed”)
end
end
end)

sorry still dont know how to embed

also make sure that hinge and door are welded

Can you try to rewrite your code with using the tip that I showed and make space between each line of script xD, it’ll be perfect! Also don’t write “ it breaks the entire script. Write "

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

local debounce = false

Proxy.Triggered:Connect(function()
	if opened == false then
		opened = true		
		for i = 1, 22 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(4), 0))
			wait()
			Proxy.ActionText = "Open"
			print("The Door is opened")
		end	
	else
		opened=false
		for i = 1, 22 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-4), 0))
			wait()
			Proxy.ActionText = "Closed"
			print("The Door is closed")
		end		
	end	
end) ```
1 Like

Is that good? works for you?
(charrrrr)

Great it works perfectly! Good job zhenjie!
But you can’t use TweenService for this script ?

I could but you siad you didn’t want tweenservice

That’s true, I didn’t want because it’s harder to script with Tween Service but it makes less lags using it! Your message will be the Solution if you’re able to use TweenService. If you can’t I’ll put the solution for CFrame way!

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

local TS = game:GetService("TweenService")

local openCFrame = Hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
local closeCFrame = Hinge.CFrame

local openTween = TS:Create(Hinge, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = openCFrame})
local closeTween = TS:Create(Hinge, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = closeCFrame})

local debounce = false

Proxy.Triggered:Connect(function()
	if opened == false then
		opened = true		
		openTween:Play()
		Proxy.ActionText = "Open"
		print("The Door is opened")
	else
		opened=false
		closeTween:Play()
		Proxy.ActionText = "Closed"
		print("The Door is closed")	
	end	
end) ```

Edit tweens to your will!  Also make sure that the door is unanchored but the hinge can be anchored.  Don't worry since they are welded the door won't fall.

Also you don't have to add debounce variable it is useless.
1 Like

So I tested, my output shows me an error:
image
I welded Hinge to Door, and Door is unanchored!

EDIT : All work! You just forgot to mention the first line of my script thank you very much!

No problem! Before this I didn’t even know Proximity Prompt was a thing so thank you for showing me this! This is very useful.

1 Like

You’re welcome! In the DevForum Roblox, we could learn scripts and features together!