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

Focus Camera on a Target?

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

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)

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