Needing support on making a locally-opened door with a key

I’m attempting to achieve to make a locally-opened door for a game, locally mostly because I really don’t want people to keep opening the door for everyone. This is a localscript under a part as it’s parent.

The code I have currently, is:

script.Parent.Touched:Connect(function()
	local key = game.Players.LocalPlayer.Backpack:FindFirstChild("Key")
	
	if key then
		local tag = key:FindFirstChild("canOpen")
		
		if tag then
			script.Parent.Transparency = 0.5
			script.Parent.CanCollide = false
		end
	end
end)

Thank you! :smile:

What exactly is canOpen, inside of the key? If it’s a Value then change to:

local tag = key:FindFirstChild("canOpen").Value

canOpen is inside the tool itself, it doesnt have a parent. It’s also a boolvalue.

Then the above should work! Since canOpen is found inside the tool, you obtained it correctly. But to access the value of the boolean, you need to also specify the .Value in the end.

Do you also make sure to give the player the key at some point (set the canOpen.Value = true) ?

Alright! I’ll test that soon, I have to help my friend revamp his game. Thank you!