Door Script Issue

Hello I try to make KeypadDoor when you enter the correct answer it will open
also, this script can be reused like when you open Door1 you still can use this to open Door2
but the problem is when I unlock one of the door another door can’t be used (UI didn’t show up)

Door Script

local Click = script.Parent.ClickDetector
local used = script.Parent.Parent.used
local Event = game.ReplicatedStorage.KeypadDoorEvent
local Owner = script.Parent.Parent.Name

Click.MouseClick:Connect(function(Player)
	if used.Value == false then
		repeat  Player.PlayerGui.KeyPadGui.Enabled = true

		until  Player.PlayerGui.KeyPadGui.Enabled == true
		Event:FireAllClients(Owner)
		used.Value = true
	end
end)

Explorer
image

LocalScript

local OwnerSignalEvent = game.ReplicatedStorage.KeypadDoorEvent
local TextEvent = script.Parent.Parent.TextHere
local Button = script.Parent
Debounce = false


OwnerSignalEvent.OnClientEvent:Connect(function(Signal)
local FindOwner = game.Workspace.KeypadDoor:FindFirstChild(Signal)
print(FindOwner)
		Button.MouseButton1Up:Connect(function()
			if Debounce == false then
					Debounce = true
if script.Parent.Parent.Parent.Enabled == true then
local Answer = FindOwner.Answer
	local ScreenText = FindOwner.Screen.SurfaceGui.TextLabel
			if TextEvent.Text == Answer.Value then
				FindOwner.Screen.SurfaceGui.TextLabel.Text = TextEvent.Text
				TextEvent.TextColor3 = Color3.fromRGB(43, 255, 28)
				ScreenText.TextColor3 = Color3.fromRGB(43, 255, 28)
						script.Parent.Parent.Parent.Enabled = false
      wait(0.5)
     FindOwner.Door:Destroy()
     FindOwner.Keypadhere.ClickDetector:Destroy()
     FindOwner.used.Value = false
					TextEvent.Text = " "
					Debounce = false
					TextEvent.TextColor3 = Color3.fromRGB(255, 255, 255)
			else
				FindOwner.Screen.SurfaceGui.TextLabel.Text = TextEvent.Text
				TextEvent.TextColor3 = Color3.fromRGB(255, 0, 0)
				ScreenText.TextColor3 = Color3.fromRGB(255, 0, 0)
				wait(0.5)
				TextEvent.TextColor3 = Color3.fromRGB(255, 255, 255)
				ScreenText.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
	end
end)
end)

Explorer
image

--SERVER

local DoorPart = script.Parent
local Door = DoorPart.Parent
local Click = DoorPart.ClickDetector
local used = Door.used

local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated.KeypadDoorEvent

Click.MouseClick:Connect(function(Player)
	if not used.Value then
		used.Value = true
		Player.PlayerGui.KeyPadGui.Enabled = true
		Event:FireAllClients(Door.Name)
	end
end)

Event.OnServerEvent:Connect(function(Player, Owner)
	Player.PlayerGui.KeyPadGui.Enabled = false
	Owner.Door:Destroy()
	Owner.Keypadhere.ClickDetector:Destroy()
	Owner.used.Value = false
end)
--LOCAL

local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated:WaitForChild("KeypadDoorEvent")
local Button = script.Parent
local Frame = Button.Parent
local Gui = Frame.Parent
local TextHere = Frame:WaitForChild("TextHere")

local Debounce = false

Event.OnClientEvent:Connect(function(DoorName)
	local KeypadDoor = workspace.KeypadDoor
	local FindOwner = KeypadDoor:FindFirstChild(DoorName)
	if FindOwner then
		Button.MouseButton1Up:Connect(function()
			if Debounce then
				return
			end
			Debounce = true
			
			if Gui.Enabled then
				local ScreenText = FindOwner.Screen.SurfaceGui.TextLabel
				if TextHere.Text == FindOwner.Answer.Value then
					FindOwner.Screen.SurfaceGui.TextLabel.Text = TextHere.Text
					TextHere.TextColor3 = Color3.new(0, 1, 0)
					ScreenText.TextColor3 = Color3.new(0, 1, 0)
					task.wait(0.5)
					Event:FireServer(FindOwner)
					TextHere.Text = " "
					TextHere.TextColor3 = Color3.new(1, 1, 1)
				else
					FindOwner.Screen.SurfaceGui.TextLabel.Text = TextHere.Text
					TextHere.TextColor3 = Color3.new(1, 0, 0)
					ScreenText.TextColor3 = Color3.new(1, 0, 0)
					task.wait(0.5)
					TextHere.TextColor3 = Color3.new(1, 1, 1)
					ScreenText.TextColor3 = Color3.new(1, 1, 1)
				end
			end
			
			Debounce = false
		end)
	end
end)

You were setting the “Value” property of the “BoolValue” instance named “used” to false from the client (this change won’t replicate to the server, I’ve made the necessary edits so that the server is fired by the client and the value change is performed on the server (such that it replicates to each client).

Your script will show the gui menu only once. It has to be this way:

local DoorPart = script.Parent
local Door = DoorPart.Parent
local Click = DoorPart.ClickDetector
local used = Door.used

local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated.KeypadDoorEvent

Click.MouseClick:Connect(function(Player)
	if not used.Value then
		used.Value = true
		Event:FireAllClients(Door.Name)
	end
end)

Event.OnServerEvent:Connect(function(Player, Owner)
	Owner.Door:Destroy()
	Owner.Keypadhere.ClickDetector:Destroy()
	Owner.used.Value = false
end)
local Replicated = game:GetService("ReplicatedStorage")
local Event = Replicated:WaitForChild("KeypadDoorEvent")
local Button = script.Parent
local Frame = Button.Parent
local Gui = Frame.Parent
local TextHere = Frame:WaitForChild("TextHere")

local Debounce = false

Event.OnClientEvent:Connect(function(DoorName)
	Gui.Enabled = true
	local KeypadDoor = workspace.KeypadDoor
	local FindOwner = KeypadDoor:FindFirstChild(DoorName)
	if FindOwner then
		Button.MouseButton1Up:Connect(function()
			if Debounce then
				return
			end
			Debounce = true
			
			if Gui.Enabled then
				local ScreenText = FindOwner.Screen.SurfaceGui.TextLabel
				if TextHere.Text == FindOwner.Answer.Value then
					FindOwner.Screen.SurfaceGui.TextLabel.Text = TextHere.Text
					TextHere.TextColor3 = Color3.new(0, 1, 0)
					ScreenText.TextColor3 = Color3.new(0, 1, 0)
					task.wait(0.5)
					Gui.Enabled = false
					Event:FireServer(FindOwner)
					TextHere.Text = " "
					TextHere.TextColor3 = Color3.new(1, 1, 1)
				else
					FindOwner.Screen.SurfaceGui.TextLabel.Text = TextHere.Text
					TextHere.TextColor3 = Color3.new(1, 0, 0)
					ScreenText.TextColor3 = Color3.new(1, 0, 0)
					task.wait(0.5)
					TextHere.TextColor3 = Color3.new(1, 1, 1)
					ScreenText.TextColor3 = Color3.new(1, 1, 1)
				end
			end
			
			Debounce = false
		end)
	end
end)
--SERVER
Click.MouseClick:Connect(function(Player)
	if not used.Value then
		used.Value = true
		Player.PlayerGui.KeyPadGui.Enabled = true --Change is made by the server thus it will replicate to all clients.
		Event:FireAllClients(Door.Name)
	end
end)

Event.OnServerEvent:Connect(function(Player, Owner)
	Player.PlayerGui.KeyPadGui.Enabled = false --Change is made by the server thus it will replicate to all clients.
	Owner.Door:Destroy()
	Owner.Keypadhere.ClickDetector:Destroy()
	Owner.used.Value = false
end)

--LOCAL
if Gui.Enabled then --This check is being performed on the client-side but because the changes occured on the server they have replicated to the client and thus the property's value has been correctly updated.

That actually isn’t the case, because the changes are being made on the server they will replicate to the client (the changes don’t need to be made locally).

I’ve provided the relevant parts of the script above and attached some comments which should help explain everything.