Script saying CFrame argument missing or nil

Hi. Currently, I am working on a rocket launcher for my game, but wen I go to shoot, the function to set the rockets CFrame is saying the first argument is either missing or nil. Here is the script:

Tool.Activated:Connect(function()
	if Tool.Enabled == true then
		Tool.Enabled = false
		local SpawnPosition = (Tool.Handle.CFrame * CFrame.new(5, 0, 0)).p
		print(SpawnPosition)
		local RocketCFrame = CFrame.lookAt(SpawnPosition, GetMouse:InvokeClient())

		
		local FiredRocket = Rocket:Clone()		--Setup rocket
		FiredRocket.CFrame = RocketCFrame 
		FiredRocket.Position = SpawnPosition
		FiredRocket.Velocity = RocketCFrame.LookVector * 60
		FiredRocket.Parent = game.Workspace
	end
end

Thanks for taking your time to read this.

local SpawnPosition = (Tool.Handle.CFrame * CFrame.new(5, 0, 0)).p

I think should be

local SpawnPosition = (Tool.Handle.CFrame * CFrame.new(Vector3.new(5, 0, 0))).p

I believe you have to supply a vector3 and not just the numbers.

1 Like

local RocketCFrame = CFrame.lookAt(SpawnPosition, GetMouse:InvokeClient())

This line is most likely the problem, I’d imagine the getmouse invoke is returning nil be sure to print the results of it; Also what did the print(SpawnPosition) output?

2 Likes

local RocketCFrame = CFrame.lookAt(SpawnPosition, GetMouse:InvokeClient())

After this assignment expression, the variable “RocketCFrame” is still a reference to a nil value, so when you index the “CFrame” property of the fired rocket and assign it this nil value an error is thrown/raised as the “CFrame” property can only be assigned a “CFrame” value of the “CFrame” class.

It’s saying that the first argument is missing, not the second.

I think your on to something, but can you please reword this? I’m having trouble understanding what your trying to say.