so whats supposed to happen is when you click the button the script checks if you have the key for it or not and if you do then the door will open.
local clickdetector = script.Parent.ClickDetector -
local key = game.StarterPack.VaultKey -- has a red underline under "local"
local player = game.Players.Name
local button = script.Parent
local vaultdoor = script.Parent.Parent.Vaultdoor
vaultKey = false
go1 = false
pkey = false
print("part1")
clickdetector.MouseClick:Connect(function()
print("part2")
local player = game.Players.PlayerAdded
print("part3")
local ToolName = "VaultKey"
if player.Backpack:FindFirstChild(ToolName) then -- error 16:15:54.811 - Backpack is not a valid member of RBXScriptSignal
print("part4")
vaultKey = true
pkey = true
if vaultKey == true then
print("part5")
if pkey == true then
button.BrickColor = BrickColor.new("Bright green")
vaultdoor.Position = Vector3.new()
go1 = true
local TweenService = game:GetService("TweenService")
local goal = {}
goal.Position = Vector3.new(-28.08, 5.76, -14.415)
local tweenInfo = TweenInfo.new(0.2*9) -- (0.5*9)
print("part6")
local tween = TweenService:Create(vaultdoor, tweenInfo, goal)
if go1 == true then
print("part7")
tween:Play()
end
else
print("part8")
button.BrickColor = BrickColor.new("Really red")
end
end
else
print("part9")
vaultKey = false
pkey = false
end
end)