What the script is supposed to be doing is using invisible parts in a folder inside of the model to help tween the two doors vertically and then close them again when a player isn’t close enough to the door. Unfortunately the doors aren’t being opened whatsoever and I’m not getting any errors in output. It’s probably an easy thing to fix but I guess I’m “tone deaf” when it comes to scripts. (as in I just have a hard time understanding what’s wrong when there’s no obvious errors.) Let me know if I should include an image of how my model is set-up, in case that’ll help.
Here’s the script:
local ServerScriptService = game:GetService("ServerScriptService")
local CollectionService = game:GetService("CollectionService")
local Functions = ServerScriptService:WaitForChild("Functions")
local Connection = {}
function applyCode(Inst)
if not Inst:IsA("Model") then return end
Connection[Inst] = {}
local Goal = {
Open = {
Door1 = Inst:WaitForChild("Goals"):WaitForChild("Open"):WaitForChild("Door1_Open"),
Door2 = Inst:WaitForChild("Goals"):WaitForChild("Open"):WaitForChild("Door2_Open")
},
Close = {
Door1 = Inst:WaitForChild("Goals"):WaitForChild("Close"):WaitForChild("Door1_Close"),
Door2 = Inst:WaitForChild("Goals"):WaitForChild("Close"):WaitForChild("Door2_Close")
}
}
if Inst:GetAttribute("Disabled") then return end
local Closed = true
for i,v in pairs(game.Players:GetChildren()) do
if v and v.Character and v.Character:FindFirstChild("HumanoidRootPart") then
if (v.Character:WaitForChild("HumanoidRootPart").Position - Inst:WaitForChild("Hitbox").Position) .Magnitude <= 10 then
Closed = false
end
if Closed == true then
Functions:WaitForChild("ClientTween"):Invoke(Inst:WaitForChild("Door1"):WaitForChild("Part"), {1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut}, {
CFrame = Goal["Close"].Door1.CFrame})
Functions:WaitForChild("ClientTween"):Invoke(Inst:WaitForChild("Door2"):WaitForChild("Part"), {1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut}, {
CFrame = Goal["Close"].Door2.CFrame})
else
Functions:WaitForChild("ClientTween"):Invoke(Inst:WaitForChild("Door1"):WaitForChild("Part"), {1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut}, {
CFrame = Goal["Open"].Door1.CFrame})
Functions:WaitForChild("ClientTween"):Invoke(Inst:WaitForChild("Door2"):WaitForChild("Part"), {1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut}, {
CFrame = Goal["Open"].Door2.CFrame})
end
end
end
end
task.spawn(function()
local Tagged = CollectionService:GetTagged("DoubleDoor")
for count=1, #Tagged do
local Inst = Tagged[count]
task.spawn(function()
applyCode(Inst)
end)
end
end)
CollectionService:GetInstanceAddedSignal("DoubleDoor"):Connect(function(Inst)
task.spawn(function()
applyCode(Inst)
end)
end)
CollectionService:GetInstanceRemovedSignal("DoubleDoor"):Connect(function(Inst)
if not Connection[Inst] then return end
for count=1, #Connection[Inst] do
local con = Connection[count]
con:Disconnect()
end
Connection[Inst] = nil
end)