What I am basically trying to do is a camera system.
How im trying to make it work is that, relative to the centerpoint of the mouse, the camera position will shift a specific direction but, first i need the screen resolution to do that. In my code, i kinda just had to guess the players screen resolution, any help?
local camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local zoom = 24
local uis = game:GetService("UserInputService")
local min_zoom= 10
local max_zoom = 36
local zoom_increment = 2
local mouse = plr:GetMouse()
mouse.WheelForward:Connect(function()
zoom -= zoom_increment
end)
mouse.WheelBackward:Connect(function()
zoom += zoom_increment
end)
game["Run Service"].RenderStepped:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
zoom = math.clamp(zoom,min_zoom,max_zoom)
local pos = uis:GetMouseLocation()
local offset_x = pos.X/1920 - 0.5
local offset_y = pos.Y/1080 - 0.5
camera.CFrame = CFrame.new(char:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,zoom,0),char:WaitForChild("HumanoidRootPart").Position) * CFrame.Angles(0,0,math.pi/2) * CFrame.new(offset_x * 2,-offset_y * 2,0)
end)
Pls let me know :))))