Camera not staying in place

I have scripted some to code to have the camera move into a certain spot, but whenever it completes it just resets back to the player, im pretty sure I need to update the cameras position so that it stays put but the problem is that I don’t know how to go about doing that.
-heres the script

local camera = workspace.CurrentCamera
local players = game.Players.LocalPlayer
local focus = workspace.MonitorCasing.MonitorOn
local endpart = workspace.EndPart
local tween = game:GetService("TweenService")
local onscreen = false

camera.CameraType = Enum.CameraType.Scriptable

local info = TweenInfo.new(
	
	1.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	false,0
	
)

workspace.MonitorCasing.MonitorOn.ClickDetector.MouseClick:Connect(function()
	
	tween:Create(camera, info, {CFrame = focus.CFrame, CFrame = endpart.CFrame}):play()
	onscreen = true
	
end)

The script seems to be ok. Try changing the camera subject to the endpart if you can.

Maybe thats why the camera always resets…

This has in a way fixed my problem, it set the cameras origin to the endpart but im still able to move it around instead of it staying put

Look i made that for you. Should work now:

local camera = workspace.CurrentCamera
local players = game.Players.LocalPlayer
local focus = workspace.MonitorCasing.MonitorOn
local endpart = workspace.EndPart
local tween = game:GetService("TweenService")
local onscreen = false

camera.CameraType = Enum.CameraType.Scriptable -- This is at the wrong location

local info = TweenInfo.new(
	
	1.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	false,0
	
)

workspace.MonitorCasing.MonitorOn.ClickDetector.MouseClick:Connect(function()
	
	camera.CameraType = Enum.CameraType.Scriptable -- Move it here!
	
	tween:Create(camera, info, {CFrame = focus.CFrame, CFrame = endpart.CFrame}):play()
	onscreen = true
	
end)

The problem was very simple: before the tween starts, the camera type wasnt changed to scriptable. Even you wrote it at the beginning. I think roblox resets this after some time.

Thank you, this has fixed my problem but for some reason the camera moves inside of the model instead of stopping at the endpart.

1 Like

I recreated the scene in the studio and the camera stops inside of the End Part for me.

Check whether you have determined the corrected parts for the variables or whether you accidentally head the camera towards the model in the following lines of code.

Thank you so much for helping me figure this out, the reason why this was happeing was because after it Tweened I set the camera type to fixed which somehow moved the camera forward.

1 Like

Sometimes everything is easier than you imagine :slight_smile: