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)
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.CFrameCFrame.Angles(0, math.rad(-4), 0))
wait()
Proxy.ActionText = “Closed”
print(“The Door is closed”)
end
end
end)
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) ```
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.