Hi, I want the door to only open if the player has a tool called "Key2310" in their inventory. The script is in a server script so that all other players can see the door open. Can somebody help me pls?

local Hinge = script.Parent.Scharnier
local opened = false

function open()
	if opened == false then
		opened = true
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(math.rad(6), 0, 0))
			wait()
		end
	else
		opened = false
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(math.rad(-6), 0, 0))
			wait()
		end
	end
end

---
local plr = game.Players.LocalPlayer
local key = plr.Backpack:FindFirstChild("Key2310")

function check()
	if key then
		open()
	end
end

script.Parent.ClickDetector.MouseClick:Connect(check)