I'm working on a valve animation that twists the valve left and right. At first I was gonna make it so a ProximityPrompt would trigger it, but I decided to test just the left animation to see if it worked.

I used ClickDetector:Connect to connect clicking the valve to a function that prints a test message then makes the tween and runs it. I already knew that the script had an error, but I just wanted to make sure it would run.

However, when I tried to test the script by clicking on the valve, nothing would output but an error that printed once saying Workspace.MeshPart.ClickDetector.Script:5: invalid argument #1 (CFrame expected, got Instance).

My 2 questions are:

  1. Why does the script output this error?
  2. Why doesn't the ClickDetector script run?

Notes: The valve is a MeshPart The valve is located in Workspace.MeshPart.ClickDetector.Script

Script:

local TweenService = game:GetService("TweenService")

local left = {}

left.CFrame = script.Parent.Parent * CFrame.Angles(math.rad(-30), 0, 0)

local right = {}

--right.CFrame = CFrame.Angles(math.rad(-30), 0, 0) (commented because it has nothing to do with the script itself)

local datime = TweenInfo.new(0.5)

script.Parent.MouseClick:Connect(function()
	print("Agony")
	local ltween = TweenService:Create(script.Parent.Parent, datime, left)
	ltween:Play()
end)