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

Focus Camera on a Target?

Asked by 6 years ago

Hey there! im trying to get the current camera get focused on a part, or target, so when i move my mouse to the sides it doesnt let me, and it keeps focusing on that part even if i move my character to the sides. like when you lock an enemy on For Honor. currently i have this:

local cam = workspace.CurrentCamera local point = game.Workspace.PrimaryPart.point

cam.CameraType = "Scriptable" cam.CoordinateFrame = point.CFrame

1 answer

Log in to vote
0
Answered by 6 years ago

Use code blocks and don't use "" Strings in place of enums.

-- Local Script
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

mouse.Move:Connect(function() -- Fires when the mouse moved
    if mouse.Target ~= nil then -- make sure their mouse is not targeting the sky 
        game.Workspace.CurrentCamera.CameraSubject = mouse.Target
    end 
end)
Ad

Answer this question