(SOLVED) I've been trying for 2 hours to get this camera script to work

Script:

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)

image

It’s a camera script for a main menu. For some reason it won’t set the camera to the CameraPart. No error messages

Not working and just doing the normal camera:

Please help.

Local scripts don’t run in workspace outside of the player’s character, unless they are scripts with RunContext Client. 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)
1 Like

CurrentCamera.CameraType = "Scriptable"

Thank you!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.