local cf = script.Parent.CFrame
script.Parent.Touched:Connect(function(hit) end)
if hit.Parent.Name == "test key" then
end
script.IsOpening.Value = true
for i = 1,16 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.18) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
end
script.IsOpening.Value = false
script.IsOpened.Value = true
if script.IsOpened.Value == true and script.IsOpening.Value == false then
script.IsOpening.Value = true
for i = 1,16 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
end
script.IsOpening.Value = false
script.IsOpened.Value = false
script.Parent.CFrame = cf
script.CloseSound:Play()
end
while true do end
wait(15)
if script.IsOpened.Value == true then
script.IsOpening.Value = true
for i = 1,16 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.18) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
end
script.IsOpening.Value = false
script.IsOpened.Value = false
script.Parent.CFrame = cf
script.CloseSound:Play()
end
in line 3, the "hit" is unknown global, sorry if im stupid im new to scripting :P

2 comments
You're ending the function before running code you expect to run inside the function.
if i delete the 'end' in the last line it says 'Expected end to close then at line 3, got