This has been driving me nuts for hours - Argument 3 missing or nil

So I’m trying to make a scuffed camera bobbing script, and I’m getting very close, a lot closer than I was.
All I’m trying to do right now is found out why the heck CFrame.Angles() won’t allow me to add CFrame:ToEulerAnglesXYZ. So far what I have is some script someone gave me a long time ago so make a part do a loop, and make it look at a part.


This could all be over if roblox would just simply add a CFrame.Orientation, but instead it is a hassle, almost impossible to get rotation out of a cframe.

Edit: one thing that could fix this is camera.cframe += …, but ofc i cant do +=.

1 Like

There’s a CFrame.Rotation in case you didn’t see that.

1 Like

watch the last 10 seconds of the second video. you can see me getting mad at it
its the exact same as cframe, cframe.rotation is useless since it is just the entire cframe

You can multiply by CFrames together, multiply by the cframe.Rotation to do what you want.

It’s a full CFrame, but minus the translation part. Can combine that rotation with another part like this:

workspace.Part.CFrame = CFrame.new(workspace.Part.CFrame.Position) * workspace.Part2.CFrame.Rotation
  • Sorry, meant to reply to general not specific post
1 Like

You can’t use humanoid.cameraoffset?

lol i didn’t know that, my bad. I tried to add the camera cframe.rotation with blue.cframe.rotation, but roblox doesnt like that. (cant attach video,error)

no, I’m trying to do camera rotation

Im pretty sure ToEulerAngles returns a tuple of 3 numbers, and adding those tuples together only returns the first values of each added together for some reason
image

from axis angle is probably what you’re looking for and what you should be using

The CFrame.Position just returns the position part of the CFrame, which is already a vector (just drops all the rotation parts). The CFrame.Rotation returns a whole CFrame with the translation part basically zeroed out.

You could translate the CFrame of a temp part by using the method I posted above and then pull the Part.Orientation from that part, or the CFrame:ToOrientation() gives pretty similar results; although it gives the angle measurements in radians instead of degrees. Can fix that with something like:

-- results similar to Part.Orientation
local x,y,z = workspace.Part.CFrame:ToOrientation()
x = math.deg(x)
y = math.deg(y)
z = math.deg(z)

I tried my best to follow your example, and luckily I got no errors, but I got this.
major flashing lights warning

i guess you can remove the math.deg() since CFrame uses radiants to set orientation

pretty much the same result, seizure inducing earthquake

i mean you can try

CFrame.Angles(x*2,y*2,z*2)

well that works, I just cant rotate the camera too.

thats because you are constantly setting the orientation to 0 when settings the cframe
Instead of CFrame.new(camera.CFrame.Position) do camera.CFrame

Can you give you full code for this? That way it will be easier to make detailed suggestions.

Sorry had to leave for a bit.
So, what is the rotation needed for? Do you want that as part of the bob, or are you trying to rotate the cam to follow the player or what?

You aiming for this kind of thing? Trying to figure out what effect you are going for.

local camera = workspace.Camera
local RunService = game:GetService("RunService")

local count = 0
RunService.RenderStepped:Connect(function(dx)
	local translate = Vector3.new(math.sin(5*count)/4 - 0.5, math.sin(2*count)/2 - 0.5, 0)
	
	local cf = camera.CFrame:ToWorldSpace(CFrame.new(translate))
	camera.CFrame = cf
	count += dx
end)

or this? (if you want the horizon to lift/fall and rly make players seasick)

local camera = workspace.Camera
local RunService = game:GetService("RunService")

local count = 0
RunService.RenderStepped:Connect(function(dx)
	local translate = Vector3.new(math.sin(5*count)/4 - 0.5, math.sin(2*count)/2 - 0.5, 0)

	local cf = camera.CFrame:ToWorldSpace(CFrame.new(translate))
	local rotate = CFrame.fromAxisAngle(cf:ToObjectSpace(camera.CFrame).RightVector, math.sin(count)/1000)
	camera.CFrame = cf * rotate
	count += dx
end)

sorry for the confusion, yes, I am trying to create some bob type effect. Heres the full code:
infinite loop code:

local runservice = game:GetService('RunService')

local part = workspace.blue
local x = part.Position.X
local y = part.Position.Y
local z = part.Position.Z
local speed = 5 -- feel free to change
local strength = 1 -- feel free to change

runservice.Heartbeat:Connect(function()
	local currentTime = tick() -- current time is the elapsed
	part.Position = Vector3.new(x + math.sin(currentTime*speed)*strength, y + math.sin(2*currentTime*speed)*strength/3, z)
	part.CFrame = CFrame.lookAt(part.Position,workspace.pink.Position)
end)

Cam Code:

local blue = workspace.blue
local player = game.Players.LocalPlayer
local char = player.Character
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local cframe1 = blue.CFrame

runService.RenderStepped:Connect(function()
	local x,y,z = blue.CFrame:ToOrientation()
	--x = math.rad(x)
	--y = math.rad(y)
	--z = math.rad(z)
	
	local x1,y1,z1 = camera.CFrame:ToOrientation()
	--x1 = math.rad(x1)
	--y1 = math.rad(y1)
	--z1 = math.rad(z1)
	
	local x2,y2,z2 = x+x1,y+y1,z+z1
	
	camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x*2,y*2,z*2) * camera.CFrame.Rotation
end)

Edit: The cam code is something I threw together trying to understand things and isnt mine