Hello, recently I made this Proximity Prompt door system and it works pretty nice, until people press the proximity prompt at the same time (or before its done tweening). Then, it either gets stuck, breaks, doesn’t close all the way, etc.
Yes, I’ve added a debounce, but it doesn’t seem to work, and I’m thinking its because I play the tweens on the server and the client at the same time, I genuinely don’t know where to attack this problem.
Heres the server script:
local tween = game:GetService("TweenService")
local door1
local player = game.Players.LocalPlayer
local access = player:WaitForChild("Access")
local Players = game:GetService("Players")
local debounce = false
local doors = game.Workspace.DoubleDoors
local Player = Players.LocalPlayer
for i,doors1 in ipairs(doors:GetDescendants()) do
if doors1:IsA("ProximityPrompt") then
local doorz = doors1
local ocf1 = doorz.Parent.Parent.LeftDoor.CFrame
local ocf2 = doorz.Parent.Parent.RightDoor.CFrame
local debounce = false
local openA = tween:Create(doorz.Parent.Parent.LeftDoor, TweenInfo.new(3.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = ocf1 * Vector3.new(0, 0, 6)})
local closeA = tween:Create(doorz.Parent.Parent.LeftDoor, TweenInfo.new (3, Enum.EasingStyle.Sine), {Position = ocf1 * Vector3.new (0, 0, -.024)})
local openB = tween:Create(doorz.Parent.Parent.RightDoor, TweenInfo.new(3.8, Enum.EasingStyle.Sine,Enum.EasingDirection.InOut), {Position = ocf2 * Vector3.new( 0,0, 6)})
local closeB = tween:Create(doorz.Parent.Parent.RightDoor, TweenInfo.new (3, Enum.EasingStyle.Sine), {Position = ocf2 * Vector3.new (0, 0, -.024)})
local allowed = {}
local paccess = {}
local opened = doorz.Parent.Parent.IsOpen
opened.Value = false
local clearance = {}
for i,v in pairs(doorz.Parent.Parent.LeftDoor.Allowed:GetChildren()) do
if v:IsA("BoolValue") then
local values = v.Name
table.insert(clearance, values)
end
end
local access = player:WaitForChild("Access")
doorz.Triggered:Connect(function()
if not table.find(clearance, access.Value) then
doorz.Parent.AccessDenied:Play()
end
if table.find(clearance, access.Value) then
if not debounce then
debounce = true
game:GetService("ReplicatedStorage"):WaitForChild("DDoorEvent"):FireServer(doorz)
doorz.Parent.Parent.Light1.BrickColor = BrickColor.new("Lime green")
doorz.Parent.Parent.Light3.BrickColor = BrickColor.new("Lime green")
openA:Play()
openB:Play()
wait(7)
closeA:Play()
closeB:Play()
doorz.Parent.Parent.Light1.BrickColor = BrickColor.new("Ghost grey")
doorz.Parent.Parent.Light3.BrickColor = BrickColor.new("Ghost grey")
wait(1.5)
debounce = false
end
end
end)
end
end
Here is the LocalScript:
local tween = game:GetService("TweenService")
local door1
local player = game.Players.LocalPlayer
local access = player:WaitForChild("Access")
local Players = game:GetService("Players")
local debounce = false
local doors = game.Workspace.DoubleDoors
local Player = Players.LocalPlayer
for i,doors1 in ipairs(doors:GetDescendants()) do
if doors1:IsA("ProximityPrompt") then
local doorz = doors1
local ocf1 = doorz.Parent.Parent.LeftDoor.CFrame
local ocf2 = doorz.Parent.Parent.RightDoor.CFrame
local debounce = false
local openA = tween:Create(doorz.Parent.Parent.LeftDoor, TweenInfo.new(3.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = ocf1 * Vector3.new(0, 0, 6)})
local closeA = tween:Create(doorz.Parent.Parent.LeftDoor, TweenInfo.new (3, Enum.EasingStyle.Sine), {Position = ocf1 * Vector3.new (0, 0, -.024)})
local openB = tween:Create(doorz.Parent.Parent.RightDoor, TweenInfo.new(3.8, Enum.EasingStyle.Sine,Enum.EasingDirection.InOut), {Position = ocf2 * Vector3.new( 0,0, 6)})
local closeB = tween:Create(doorz.Parent.Parent.RightDoor, TweenInfo.new (3, Enum.EasingStyle.Sine), {Position = ocf2 * Vector3.new (0, 0, -.024)})
local allowed = {}
local paccess = {}
local opened = doorz.Parent.Parent.IsOpen
opened.Value = false
local clearance = {}
for i,v in pairs(doorz.Parent.Parent.LeftDoor.Allowed:GetChildren()) do
if v:IsA("BoolValue") then
local values = v.Name
table.insert(clearance, values)
end
end
local access = player:WaitForChild("Access")
doorz.Triggered:Connect(function()
if not table.find(clearance, access.Value) then
doorz.Parent.AccessDenied:Play()
return
end
if table.find(clearance, access.Value) then
if not debounce then
debounce = true
game:GetService("ReplicatedStorage"):WaitForChild("DDoorEvent"):FireServer(doorz)
doorz.Parent.Parent.Light1.BrickColor = BrickColor.new("Lime green")
doorz.Parent.Parent.Light3.BrickColor = BrickColor.new("Lime green")
openA:Play()
openB:Play()
wait(7)
closeA:Play()
closeB:Play()
doorz.Parent.Parent.Light1.BrickColor = BrickColor.new("Ghost grey")
doorz.Parent.Parent.Light3.BrickColor = BrickColor.new("Ghost grey")
wait(1.5)
debounce = false
end
end
end)
end
end
I’ve pretty much tried all I can with my little scripting knowledge (kinda beginner)