local RunService = game:GetService("RunService")
local players = game:GetService("Players")
local CameraPart = workspace:WaitForChild("CameraPart")
local CurrentCamera = workspace.CurrentCamera
local LocalPlayer = players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local MOVE_SPEED = 150
local function UpdateCamera()
local Center = CameraPart.CFrame
local MoveVector = Vector3.new((Mouse.X - Center.X)/MOVE_SPEED, (Mouse.Y - Center.Y)/MOVE_SPEED, 0)
CurrentCamera.CFrame = CameraPart.CFrame * CFrame.Angles(math.rad(-(Mouse.Y - Center.Y)/MOVE_SPEED), math.rad(-(Mouse.X - Center.Y)/MOVE_SPEED), 0)
end
local Connection = RunService.RenderStepped:Connect(UpdateCamera)
It’s a camera script for a main menu. For some reason it won’t set the camera to the CameraPart. No error messages
Local scripts don’t run in workspace outside of the player’s character, unless they are scripts with RunContextClient. Place the script in StarterPlayerScripts or StarterCharacterScripts.
Other than that, the camera type should be Scriptable.
Minor modifications
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local MOVE_SPEED = 150
local LocalPlayer = Players.LocalPlayer
local CurrentCamera = workspace.CurrentCamera
local CameraPart = workspace:WaitForChild("CameraPart")
local Mouse = LocalPlayer:GetMouse()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local function UpdateCamera()
local Center = CameraPart.CFrame
local MoveVector = Vector3.new((Mouse.X - Center.X)/MOVE_SPEED, (Mouse.Y - Center.Y)/MOVE_SPEED, 0)
CurrentCamera.CFrame = CameraPart.CFrame * CFrame.Angles(math.rad(-(Mouse.Y - Center.Y)/MOVE_SPEED), math.rad(-(Mouse.X - Center.Y)/MOVE_SPEED), 0)
end
local Connection = RunService.RenderStepped:Connect(UpdateCamera)