so what i mean by that is im checking to see if something exists, and if it doesnt text says its locked. but the text cant show up because it errors saying the Value doesnt exists when it isnt supposed to, is there a better way to check?
local key1 = workspace.Key1
script.Parent.ClickDetector.MouseClick:connect(function(click)
local moving = false
if moving == false then
moving = true
if click.Backpack.Key1 then
key1.Sound:Play()
key1.Sound:Destroy()
key1.ClickDetector:Destroy()
game.Players.LocalPlayer.Backpack.Key1:Destroy()
local num = 0
repeat
num = num + 1
key1.CFrame = key1.CFrame * CFrame.new(0, 0, 0.35) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
until num > 17
end
else
script.Parent.Text = "Hmm... Its locked..."
script.Parent.Visible = true
for i= 1,10 do
wait()
script.Parent.TextTransparency = 1-(i*0.1)
end
wait(2)
for i= 1,10 do
wait()
script.Parent.TextTransparency = (i*0.1)
end
end
end)
Error: > 22:30:45.418 - Key1 is not a valid member of Backpack

5 comments
It still gives me the error
Can you tell me which line exactly errors?
no it just says that Key1 doesnt exist
but its not supposed to exist untill you get the key
It should look something like this, it always gives you the script name and its parenting and the line number: 00:18:14.034 - Key1 is not a valid member of Backpack 00:18:14.035 - Script 'ServerScriptService.Script', Line 1 --- This line right here