So basically I want the door to open if the player has the correct key, but now I'm rethinking what if the player has more than one key in the backpack. How should I have it check each key?
The Script:
local Open = script.Parent.Open.Value
function OpenDoor()
script.Parent.Frame.Transparency = 1
script.Parent.Frame.CanCollide = false
script.Parent.Knob.Transparency = 1
script.Parent.Knob.CanCollide = false
script.Parent.Frame2.Transparency = 0
script.Parent.Frame2.CanCollide = true
script.Parent.Knob2.Transparency = 0
script.Parent.Knob2.CanCollide = true
script.Parent.OpenFX:Play()
Open = true
end
function CloseDoor()
script.Parent.Frame.Transparency = 0
script.Parent.Frame.CanCollide = true
script.Parent.Knob.Transparency = 0
script.Parent.Knob.CanCollide = true
script.Parent.Frame2.Transparency = 1
script.Parent.Frame2.CanCollide = false
script.Parent.Knob2.Transparency = 1
script.Parent.Knob2.CanCollide = false
script.Parent.CloseFX:Play()
Open = false
end
function ClickOpen(Player)
if Open == false and Player.Backpack.Key then
if script.Parent.Broken.Value == false and Player.Backpack.Key.Grooves.Value == "E2SGF3G5" then
OpenDoor()
end
end
end
function ClickClose()
if Open == true then
if script.Parent.Broken.Value == false then
CloseDoor()
end
end
end
function Knock()
if Open == false then
script.Parent.KnockFX:Play()
end
end
script.Parent.Knob.ClickDetector.MouseClick:Connect(ClickOpen)
script.Parent.Knob2.ClickDetector.MouseClick:Connect(ClickClose)
script.Parent.Frame.ClickDetector.MouseClick:Connect(Knock)
Layout

1 comment
Thing is the parts are not base parts, and the key is suppost to be named key but have different values inside