CurrentCamera doesn't work normally after I use my shop script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make a shop can be useable with cameras.

  2. What is the issue? The issue is that I can’t get back to my normal camera after I use the shop. Here is my video: https://gyazo.com/fc3776eb82adda13af1813a04a6f79b1

  3. What solutions have you tried so far? Yes I did look for solutions on the forum but I couldn’t find anything related to my question or I don’t know how to ask this issue.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Here is my LocalScript

local waitTime = 5 -- Wait a few seconds before clicking anything.
wait(waitTime)

local maxCamValue = 3 -- This is how many cams are in workspace.

local camValue = script.Cam.Value

lastCam = nil -- This is where the camera is going to move.

local leftArrow = script.Parent.Left
local rightArrow = script.Parent.Right
local cancel = script.Parent.Cancel

local function moveCamera()
	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable
	lastCam = workspace:FindFirstChild("Cam"..camValue)
	for i = 0,1,0.001 do
		camera.CFrame = camera.CFrame:Lerp(lastCam.CFrame,i)
		wait()
	end
end
rightArrow.MouseButton1Down:connect(function()
	 camValue = camValue + 1
	 if camValue >= maxCamValue + 1 then
		  camValue = 1
	 end
	moveCamera()
end)

leftArrow.MouseButton1Down:connect(function()
	 camValue = camValue - 1
	 if camValue <= 0 then
		  camValue = 4
	 end
	moveCamera()
end)

cancel.MouseButton1Down:Connect(function()
	camValue = 0
	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)

I want to know how to get back to my normal camera.
I think I have done something wrong with CFrames.

1 Like

I’m not 100% sure but i’m going to say it’s because the camera is still lerping even after you set the cameratype to custom. I would recommend using TweenService for this, I stopped using lerp for cinematic effects a long time ago because of the amount of bugs caused by overriding a lerp, So i’m not sure if setting the cameratype to custom forces the lerp to end.

2 Likes

As @MightTea mentioned, Tween Service Is much more efficient and would work better than lerping.

You can simply just make a folder with all your camera positions or offset the camera from your objects and then Tween It’s CFrame.