I made a code so that many doors with the same name work individually with some allowed items and I did this in a serverscriptservice but when the doors open I give them to interact again and they do not close, what do I do?
Yes, it is done with remote event and everything works, what does not work is what I am explaining
my code here:
local evento = game.ReplicatedStorage.DoorFuntion.OpenDoors
local tween = game:GetService("TweenService")
local infodoor = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
evento.OnServerEvent:Connect(function(player, puerta)
local access = puerta:FindFirstChild('clearances')
local modulo = require(access)
local door1 = puerta:FindFirstChild("door1")
local door2 = puerta:FindFirstChild("door2")
local open = puerta:FindFirstChild("open")
local p1 =puerta:FindFirstChild("bpos1")
local p2 = puerta:FindFirstChild("bpos2")
local abrirdoor1 = {
CFrame = p1.CFrame:ToWorldSpace(CFrame.new(0, 0, 0))
}
local abrirdoor2 = {
CFrame = p2.CFrame:ToWorldSpace(CFrame.new(0, 0, 0))
}
local cerrardoor1 = {
CFrame = door1.CFrame
}
local cerrardoor2 = {
CFrame = door2.CFrame
}
local close1 = tween:Create(door1,infodoor,cerrardoor1)
local close2 = tween:Create(door2,infodoor,cerrardoor2)
local open1 = tween:Create(door1,infodoor,abrirdoor1)
local open2 = tween:Create(door2,infodoor,abrirdoor2)
local deb = false
local character = player.Character
for i, keys in pairs(player.Backpack:GetChildren(modulo)) do
if modulo[keys.Name] == true then
if open.Value == false then
open1:Play()
open2:Play()
wait(1.1)
open.Value = true
break
else
close1:Play()
close2:Play()
wait(1.1)
open.Value = false
break
end
end
end
end)