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.
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)
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)