So do I make something like this, if tried looking for other posts but none get this right, I have attempted making it with no success, any help on where to get started?
1 Like
This should help you:
I have seen this post, tried it, doesn’t really work with what I originally needed
Ok, I have modified the code ALL BY MYSELF and it should behave the same you wanted:
(seriously thanks @A_Chim for contributing, it took me 10000000 years to finish.)
(I couldn’t fix the cam following the part lookvector)
local mouse = game.Players.LocalPlayer:GetMouse()
local cam = workspace.CurrentCamera
local camPart = workspace.campart
local Scale = 5000
cam.CameraType = Enum.CameraType.Scriptable
game:GetService("RunService").RenderStepped:Connect(function()
local center = Vector2.new(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
local x = mouse.X - center.X / 2
local y = mouse.Y - center.Y / 2
local xOffset = x/Scale
local yOffset = y/Scale
local lookAtPoint = camPart.Position+camPart.CFrame.LookVector*5
local vector = Vector3.new(
lookAtPoint.X - xOffset,
lookAtPoint.Y - yOffset,
lookAtPoint.Z - xOffset)
local result = CFrame.lookAt(camPart.CFrame.Position,vector)
cam.CFrame = result
end)
Video preview of this script:
https://gyazo.com/a542caa06b0c534b1e29716988ec5763
27 Likes