Greetings,
I have created a local script on the camera, but I have no idea how to make the camera move with the mouse.
I need to make Camera System like dota 2, so that when holding MouseButton3 (wheel), so to speak grabbed the camera and moved depending on the position of the mouse.
And I also need that when you point at the edges of the screen, the camera moved depending on what part of the screen is the mouse.
In general, I need help in creating a camera as in Dota 2, I have a ready code just on the camera lock on the player, I need to make of it what is described above, can anyone help me?
My code:
local Character = script.Parent
local Camera = workspace.CurrentCamera
local CurrentFov = 70
local zoom = 25
local Connection2
local CameraSystem = coroutine.wrap(function()
Connection2 = game:GetService("RunService").RenderStepped:Connect(function()
Camera.FieldOfView = CurrentFov
if Character then
if Character:FindFirstChild("HumanoidRootPart") then
Camera.CFrame =
CFrame.new(Vector3.new(Character.HumanoidRootPart.Position.X + zoom, Character.HumanoidRootPart.Position.Y + zoom + zoom, Character.HumanoidRootPart.Position.Z + zoom), Character.HumanoidRootPart.Position)
end
end
end)
end)
CameraSystem()
I need the camera to always look in the same direction (as in my script), but its position will change
Here is the code, it always looks from a positive offset at the character. The camera code is just the RunService stuff, but to get it working you can just put this in a local script in StarterPlayerScripts.
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local CurrentFov = 70
local Zoom = 25
local OffsetVector = Vector3.new(1, 2, 1) * Zoom
Camera.CameraType = Enum.CameraType.Scriptable -- This is important
Camera.FieldOfView = CurrentFov -- You only need to set this once / where it is changed. No need to do it in renderstepped
local CameraConnection = nil
local function CharacterAdded(Character)
-- In case of respawn, disconect the old one:
if CameraConnection then
CameraConnection:Disconnect()
end
-- New camera loop for this character:
local CameraConnection = RunService.RenderStepped:Connect(function()
local Root = Character.PrimaryPart
if Root then -- Effectively the same check
local CameraPosition = Root.Position + OffsetVector
local CameraCFrame = CFrame.lookAt(CameraPosition, Root.Position)
Camera.CFrame = CameraCFrame
Camera.Focus = CameraCFrame -- It is good to set this too, see the documentation
end
end)
end
Player.CharacterAdded:Connect(CharacterAdded)
-- If you load really fast, this might run
if Player.Character then
CharacterAdded(Player.Character)
end
thanks so much for your help, I really appreciate it 
but, I still don’t understand how to move the camera. I think you need to make a tween for OffsetVector. But I don’t understand what numbers to put in to move the camera to the right, left, above and below
Do you mean pivot? Like the angle that you are looking from?
No, I want to move the camera like in Dota 2.
here is the video, starting at 0:18 seconds, in the video the camera moves in different directions
I’m sorry I can’t explain it to you clearly, but I don’t know English very well.