Change camera position?

i have a script that changes my Character model to another while in game.

it works but it also resets the Cameras Position, which is not what i want.
i have tried to make camera.Type = “Scriptable” then setting the cframe to before it was changed, but after that i am not able to move the camera until i set it back to Custom, and when i set it back to custom, it just resets the camera again :stuck_out_tongue:

3 Likes

Could you send a video of the issue?

1 Like

https://gyazo.com/d74b7acdf390e9223a7245836defd0fc

1 Like

Oh. I see. How about setting that camera type to scriptable and then save the camera CFrame before changing the character, and setting it after?

1 Like

ah that would have been a good idea, but i have alredy tried that exact same thing as i have mentioned above

1 Like

How about setting it to “fixed”, not “custom”?

1 Like

still does not work, the camera is just fixed at a point and not following the character anymore

1 Like

How about “follow”?

1 Like

i have tried all the other camera types, does not work

1 Like

it appears that you delete your character upon switching to a new one. I think it might cause the CameraSubject property to lose its subject and reset the camera. Maybe you could try this

--Create a the new character
local initialCameraCFrame = camera.CFrame
camera.CameraSubject = newChar
--Destory old character
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = initialCameraCFrame
camera.CameraType = Enum.CameraType.Custom

Hello, can you send the script please? of resetting avatar-
Literally you only have to do
local savedcam = Camera.CFrame
– Reset plr
wait()
Camera.CFrame = savedcam

He responded in the reply that he did exactly that already.

1 Like

This is just an awkward property of the Camera working with Humanoids. There is no event to wait for when the camera is changed, so the best you can do is add a task.wait(0.1) before setting the camera CFrame to its old CFrame.

Wait for the CFrame to change before setting the camera’s CFrame once the character is added, like this:

local Players = game:GetService("Players")

local camera = workspace.CurrentCamera
local player = Players.LocalPlayer

local oldRot = CFrame.new()

player.CharacterAdded:Connect(function(character)
	camera:GetPropertyChangedSignal("CFrame"):Wait()
	camera.CFrame = CFrame.new(camera.CFrame.Position) * oldRot
end)

player.CharacterRemoving:Connect(function()
	oldRot = camera.CFrame - camera.CFrame.Position
end)
2 Likes