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
From what I can see, you've just ended the function on line 2 before you ran your code. It looks like you've also done the same thing on line 3 and 25 as well.
local cf = script.Parent.CFrame script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == "test key" 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 = true end 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 end) while true do 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 end