My Camera CFrame doesn't change

  1. What do you want to achieve?
    I want to make a a shop system like mining simulator

  2. What is the issue?
    The script works perfectly, i’ve tried to print to see if the function fully run and it does, I’ve tried to check at runtime what the CurrentCamera.CFrame was and it’s always on scriptable. The CFrame just doesn’t want to change. I get no error in my output either

  3. What solutions have you tried so far?
    Everything I said just above this message + talked with some people on discord and checked on the devforum but nothing seemed to work.

-- Tables
local easyCams = {
	easyObbyCamerasToggle = {
		[1] = easyObbyCam:WaitForChild("GrassLand"),
		[2] = easyObbyCam:WaitForChild("TheCave"),
	}
}

-- Variables
local isInUi = nil
local PartCF = 0

-- Functions
function ObbyCFrame.ChangeCams2(player: Player)
	currentCamera.CameraType = Enum.CameraType.Scriptable
	
	coroutine.wrap(function() -- don't mind this
		while true do
			task.wait()
			print(currentCamera.CameraType)
		end
	end)()
	
	local array = {easyCams.easyObbyCamerasToggle} -- array
	local TweenTime = 0.5
	PartCF += 1 -- index
	
	for i = 1, #array, 1 do
		while true do
			task.wait(2)
			
			local tween = tweenService:Create(currentCamera, TweenInfo.new(TweenTime), {CFrame = array[PartCF].CFrame})
			tween:Play() -- tweening
			tween.Completed:Wait()
		end
	end
end

Sorry for bumping I didn’t fix it yet

okay i know i call myself the worst camera scripter, but i think i’ve got an idea

try creating a part and parenting the camera to that part upon doing whatever you wanna do
(the video does not wanna load for me!!)

then tween that part instead, since the camera is parented to the part, the camera will move aswell!!
once the tween is completed, you parent the camera back to the player

replace this line

local tween = tweenService:Create(currentCamera, TweenInfo.new(TweenTime), {CFrame = array[PartCF].CFrame})

to

local tween = tweenService:Create(currentCamera, TweenInfo.new(TweenTime), {CFrame = array[i].CFrame})

what changed is that array[PartCF] is now array[i], when it was array[PartCF] it didnt change because PartCF changed once only before the loop

it does the exact same result unfortunatly

replace the local array line with this
local array = easyCams.easyObbyCamerasToggle -- array

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