Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Do I Get an Error for Not Providing an Argument and Another for if I Do?

In line 38 of my function, there is a utilization of CFrame that produces an error if I do not provide an argument, but when I provide one, it gives an error telling me I should not. Here is the function in question:

runService.RenderStepped:Connect(function()
	if detected == false and chatting == false then
		for i, npc in pairs (npcs:GetChildren()) do
			local humanoid = npc:FindFirstChild("Humanoid")
			local HMR = npc:FindFirstChild("HumanoidRootPart")		
			if humanoid and HMR then
				if(HMR.Position - characterHumanoidRoot.Position).Magnitude < 15 then
					detected = true
					detectedNPC = npc
					promptLabel:TweenSize(UDim2.new(0,50,0,50),"In", "Linear")
					print(detectedNPC.Name)
				end	
			end			
		end
	end
	if detected == true and chatting == false then
		local humanoid = detectedNPC:FindFirstChild("Humanoid")
		local HMR = detectedNPC:FindFirstChild("HumanoidRootPart")	
		if humanoid and HMR then
			if(HMR.Position - characterHumanoidRoot.Position).Magnitude > 15 then
				detected = false
				detectedNPC = nil
				promptLabel:TweenSize(UDim2.new(0,0,0,0),"Out", "Linear")
				print("no longer detected npc")
			else
				--world to screen point
				local WSTP = camera:WorldToScreenPoint(HMR.Position)
				promptLabel.Position = UDim2.new(0, WSTP.X, 0, WSTP.Y)
			end
		end
	end
	if chatting == true then
		local humanoid = detectedNPC:FindFirstChild("Humanoid")
		local HMR = detectedNPC:FindFirstChild("HumanoidRootPart")
			
		if humanoid and HMR then
			camera.CameraType = Enum.CameraType.Scriptable
			camera.CFrame = camera.CFrame:Lerp(HMR.CFrame * CFrame.new(-4,4,-7) * CFrame.fromOrientation(math.rad(-20), math.rad(215), 0) 0.07)
		end
	else 
		camera.CameraType = Enum.CameraType.Custom	
	end
end)

As shown, in line 38, when I write in the "0.07," I get the error: "Players.Khosraux.PlayerGui.NpcChatSystemGui.scriptNpcChat:153: Expected ')' (to close '(' at column 38), got '0.07'" however, when I comply and remove the 0.07 and run the game, I get the error: "Argument 3 missing or nil" which prints in my output box many times in rapid succession. There is a red underline whenever I type the 0.07 in as well. How do I rectify this? Thank you.

1 comment

0

Dont put 0.07 after the bracket.... It has to be likecamera.CFrame = camera.CFrame:Lerp(HMR.CFrame * CFrame.new(-4,4,-7) * CFrame.fromOrientation(math.rad(-20), math.rad(215), 0 , 0.07) Sorry if this is wrong I don't really use Lerp

1 answer

It appears the issue was that I was missing a comma proceeding the parenthesis, meaning it should have looked like:

camera.CFrame = camera.CFrame:Lerp(HMR.CFrame * CFrame.new(-4,4,-7) * CFrame.fromOrientation(math.rad(-20), math.rad(215), 0), 0.07)

This discussion is preserved as it was. New answers, comments, and votes are closed.