So i have a script for my main menu that when u move your mouse the camera moves too.
but the problem is that the script puts my camera in the middle of the map.
the script:
local Camera = game.Workspace.CurrentCamera
local CamPart = game.Workspace.CamPart
local GuiButton = game.StarterGui.ScreenGui.PlayButton
local localPlayer = game:GetService("Players").LocalPlayer
local char = localPlayer.Character or localPlayer.CharacterAdded:Wait()
repeat wait() until Camera.CameraSubject ~= nil
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CamPart.CFrame
local Mouse = game.Players.LocalPlayer:GetMouse()
local Camera = game.Workspace.CurrentCamera
local DefaultCFrame = Camera.CFrame
local Scale = 200
function Update()
local Center = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y/2)
local MoveVector = Vector3.new((Mouse.X-Center.X)/Scale, (Mouse.Y-Center.Y)/Scale, 0)
Camera.CFrame = DefaultCFrame * CFrame.new(DefaultCFrame.p + MoveVector)
end
game:GetService("RunService").RenderStepped:Connect(Update)
script.Parent.PlayButton.MouseButton1Click:Connect(function()
Camera.CameraType = Enum.CameraType.Custom
end)