Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years ago

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.

0
Hm. Never heard of CoordinateFrame; I assume it's CFrame. Have you tried using 'cam.CFrame'? DiamondComplex 285 — 4y
0
I will try adieking1 69 — 4y
0
Just tested it, it has the same effect as cam.CoordinateFrame adieking1 69 — 4y
0
Still getting errors? DiamondComplex 285 — 4y
View all comments (2 more)
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. Codename_Texas 27 — 4y
0
Posted a fix. DiamondComplex 285 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)
0
Multiplication symbol (*) DiamondComplex 285 — 4y
0
CFrame.new(position,lookAtPosition) has some errors. Fix for it is to set the positions in separate variables. XX DiamondComplex 285 — 4y
0
I tried that but it made the camera all wonky. adieking1 69 — 4y
0
Or Atleast when i try and edit the value of CFrame.Angles(0,0,0) adieking1 69 — 4y
View all comments (2 more)
0
Error is fixed. That's all I can do for now... DiamondComplex 285 — 4y
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. adieking1 69 — 4y
Ad

Answer this question