Camera Manipulation isn't working

Hello! Im trying to make it so that the camera focuses on a specific part’s front so that the player can see the rat, It only errors though

local Camera = workspace.Camera
local Rat = game.Workspace.Rat
local RatBody = Rat.Body
local Audio = game.ReplicatedStorage.Audio
local Transparent = 0.5

Camera.CameraType = "Scriptable"

Camera.Focus = game.Workspace.Part

-- Startup
Audio:Play()
wait(7)
for i = 100, Transparent do
	RatBody.Transparency = RatBody.Transparency - 0.01
	wait(0.1)
end
Documents/ROBLOX/AutoSaves
  09:31:18.845  ServerScriptService.Script:9: invalid argument #3 (CFrame expected, got Instance)  -  Server - Script:9
  09:31:18.846  Stack Begin  -  Studio
  09:31:18.846  Script 'ServerScriptService.Script', Line 9  -  Studio - Script:9
  09:31:18.846  Stack End  -  Studio
local Camera = workspace.Camera
local Rat = game.Workspace.Rat
local RatBody = Rat.Body
local Audio = game.ReplicatedStorage.Audio
local Transparent = 0.5

Camera.CameraType = "Scriptable"

Camera.Focus = game.Workspace.Part.CFrame

-- Startup
Audio:Play()
wait(7)
for i = 100, Transparent do
	RatBody.Transparency = RatBody.Transparency - 0.01
	wait(0.1)
end

this should work

1 Like

The script didn’t change the players camera position

Camera.CFrame = CFrame.LookAt(Camera.CFrame.Position,game.Workspace.Part.Position)

Focus is not the position and rotation of the camera rather where the simulation radius will start from

Change the Camera CFrame to chang its position

Side note
for i = 100, Transparent do
	RatBody.Transparency = RatBody.Transparency - 0.01
	wait(0.1)
end

Have a look at tween service for doing this type of stuff instead too.

local Camera = workspace.Camera
local Rat = game.Workspace.Rat
local RatBody = Rat.Body
local Audio = game.ReplicatedStorage.Audio
local Transparent = 0.5

Camera.CameraType = "Scriptable"

Camera.CFrame = game.Workspace.Part.CFrame + Vector3.new(-2, 0, 0)

-- Startup
Audio:Play()
wait(7)
for i = 100, Transparent do
	RatBody.Transparency = RatBody.Transparency - 0.01
	wait(0.1)
end

try this then

wait(0.1)
local camera = workspace.CurrentCamera
local part = workspace.Part --the camera part
camera.CameraType = Enum.CameraType.Custom
wait()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part.CFrame

-- Startup
Audio:Play()
wait(7)
for i = 100, Transparent do
	RatBody.Transparency = RatBody.Transparency - 0.01
	wait(0.1)
end

Try this script. Make it a LocalScript and place it in StarterPlayer.StarterPlayerScripts.
I always use this script and never get errors.

Thanks for helping me but, your bumping old post.

Oh, sorry about that, I didn’t even notice.

I personally found this helpful.
(CameraType | Roblox Creator Documentation)