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

My Top Down Camera Script is being buggy and i dont know what to do, Help?

I am trying to make a top down camera script yet it is not working. The error is on line 13 and the error message is:

Players.adieking1.PlayerScripts.CameraScript:13: invalid argument #2 (Vector3 expected, got CFrame)

Script:

game:GetService("ControllerService"):ClearAllChildren()

repeat wait() until game.Players.LocalPlayer.Character
local char = game.Players.LocalPlayer.Character
local cam = game.Workspace.CurrentCamera

cam.CameraType = Enum.CameraType.Scriptable
cam.FieldOfView = 70

Spawn(function()
while true do
		game:GetService("RunService").RenderStepped:wait()
		cam.CoordinateFrame = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(5, 10, -5) , char.HumanoidRootPart.Position)+ CFrame.Angles(0,0,0)-- Please note that the Angles part is for after the script works so I can adjust it then.
	end
end)

Please ask if you need any more information.

6 comments

0

Hm. Never heard of CoordinateFrame; I assume it's CFrame. Have you tried using 'cam.CFrame'?

0

I will try

0

Just tested it, it has the same effect as cam.CoordinateFrame

0

Still getting errors?

0

From what I understand, you are trying to cram CFrame value into an argument that requires a Vector3 value, the part I see that mismatches is your "+ CFrame.Angles(0,0,0), removing that seems to fix the issue, or so it seems, not sure what end result you are expecting.

0

Posted a fix.

1 answer

Use multiplication to add up two CFrames:

game:GetService("ControllerService"):ClearAllChildren()

repeat wait() until game.Players.LocalPlayer.Character
local char = game.Players.LocalPlayer.Character
local cam = game.Workspace.CurrentCamera

cam.CameraType = Enum.CameraType.Scriptable
cam.FieldOfView = 70

spawn(function()
	while true do
		game:GetService("RunService").RenderStepped:wait()
		local pose = char.HumanoidRootPart.Position + Vector3.new(5, 10, -5)
		local lookAt = char.HumanoidRootPart.Position
		cam.CFrame = CFrame.new(pose , lookAt) * CFrame.Angles(0,0,0)-- Please note that the Angles part is for after the script works so I can adjust it then.
	end
end)

6 comments

0

Multiplication symbol (*)

0

CFrame.new(position,lookAtPosition) has some errors. Fix for it is to set the positions in separate variables. XX

0

I tried that but it made the camera all wonky.

0

Or Atleast when i try and edit the value of CFrame.Angles(0,0,0)

0

Error is fixed. That's all I can do for now...

0

Thats the thing, Its not fixed. When i try to change the cameras distance from the player because i feel 10 is to close, it completely bugs out and tilts the camera in ways I don't want it to. Also as i said, the CFrame.Angles is basically unchangeable as once again, it tilts the camera in ways I don't want it to.

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