I have made an automatic door system but it seems that only one player can use the doors without them glitching. Here is the localscript for managing them. Also, I am using bridgenet.
local BridgeNet = require(RepStorage.BridgeNet)
local Closed = true
local Open = BridgeNet.CreateBridge("DoorOpen")
local Close = BridgeNet.CreateBridge("DoorClose")
local Doors = workspace.SlidingDoors:GetChildren()
local Gates = workspace.GateDoors:GetChildren()
game:GetService("RunService").RenderStepped:Connect(function()
for _, door in pairs(Doors) do
task.wait(.5)
local OpenSound = door.Hitbox.Open
local CloseSound = door.Hitbox.Close
local IsTouching = false
local Region = Region3.new(door.Hitbox.Position - (door.Hitbox.Size/2), door.Hitbox.Position + (door.Hitbox.Size/2))
local Parts = game.Workspace:FindPartsInRegion3WithWhiteList(Region, game.Players.LocalPlayer.Character:GetChildren())
for _, RegionPart in pairs(Parts) do
if RegionPart:FindFirstAncestor(game.Players.LocalPlayer.Name) then
IsTouching = true
end
end
if IsTouching then
Open:Fire(door.Name)
else
Close:Fire(door.Name)
--CloseSound:Play()
end
end
for _, gate in pairs(Gates) do
task.wait(.5)
local IsTouching = false
local Region = Region3.new(gate.Hitbox.Position - (gate.Hitbox.Size/2), gate.Hitbox.Position + (gate.Hitbox.Size/2))
local Parts = game.Workspace:FindPartsInRegion3WithWhiteList(Region, game.Players.LocalPlayer.Character:GetChildren())
for _, RegionPart in pairs(Parts) do
if RegionPart:FindFirstAncestor(game.Players.LocalPlayer.Name) then
IsTouching = true
end
end
if IsTouching then
Open:Fire(gate.Name)
Closed = false
else
if not Closed then
Close:Fire(gate.Name)
Closed = true
end
--CloseSound:Play()
end
end
end)
Help would be greatly appreciated.