Camera CFrame not changing

Greetings! im working on a morph type system between 3 types of balls and a normal player. Im working on making it keep the camera be the same just in a different sometimes the same ball.

This code is appart of a larger code but its un related to it and has like 2 other things that arnt apart of changing the camera

game.ReplicatedStorage.ChangeCamera.OnClientEvent:Connect(function(H)
	local CamC = Camera.CFrame
	if H then
		Camera.CameraSubject = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("Humanoid")
	else
		Camera.CameraSubject = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("HumanoidRootPart")
	end
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CFrame.new(0,5,0)
	Camera.CameraType = Enum.CameraType.Custom
	if workspace:FindFirstChild(game.Players.LocalPlayer.Name):HasTag("Boulder") then
		Controls:Disable()		
		else
		Controls:Enable()
	end
end)

These lines are the ones that change the camera

local CamC = Camera.CFrame
	if H then
		Camera.CameraSubject = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("Humanoid")
	else
		Camera.CameraSubject = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("HumanoidRootPart")
	end
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CFrame.new(0,5,0)
	Camera.CameraType = Enum.CameraType.Custom

Thanks for any help!

So, the problem with your code is that you change the cameratype to scriptable. This means you can change it with scripting. Then you move it, and then change it back to custom. When you change it back to custom, it goes back to where it was before.

So how would i go about keeping the CFrame the same in coustom?
if thats possible

1 Like

Well, how exactly do you want their camera to operate?

Ok so i want it like normal but when you morph to the ball or plr it doesent have that ugly choping type thing with the camera. i want it to just move to the new ball / plr at the same orientation and distance from the player

So like if the cam was pointed upwards and you morph it would be the same distance from the camera subject and orientation as the last camera subject so it would be at the same distance from plr looking upwards

Ah. Okay. That is a more complicated process. To do that, you probably would need to tween the camera, although I’m not sure that this will even work.

The first step would be to set the camera type to scriptable.

Then, we disable the player’s movement and jumping capabilities.

Then, we tween the camera to the other object with the same offset from the focus part of the camera.

Then, we change the camera’s focus part,

And finally, we set their camera type back to custom and give back their jump height and movement speed.

So basically we tween the camera to the other part and give ctrl back to the player?

my main need with this isnt making the position smooth cause normally the position would the same
cause im just reseting the character to the same place (A solution to a throw )

Yes, although we need to change the camera’s focus part to a part of the new character and tween it with some complicated CFrame stuff to make sure it will work.

So it doesn’t have to be a smooth transition?

kinda confusing but basically i just need the cameras orientation and distance from the part to be the same

So it doesent have to be smooth to get to the new part no

Okay. So the problem is that it changes to the new part but it’s not at the right orientation?

yeah the code i provided is the right position just not orientation

Ok! I’m going to do a little research and then get back to you.

Ok Tysm!!! (Character limmmmmmmmmmmmmmmmmmmmmmmmet)

Okay, sooo, I found something.

You may or may not have seen this before, but there actually is a script called freecam script in a player once they join the game,

If we put a script under “StarterPlayerScripts” and name it CameraScript, it will replace it.

We need to copy roblox’s script, put it under starterplayerscripts, and edit one line of code.

Somebody shows how to do it in this post:

Hope this helps!

I also do gtg now, so if you still need any help, I’ll have to help you later.

Good luck!