Camera not following the camera subject properly

I’m attempting to make a rocket flying game, yet when the player goes to launch the camera does not follow the rocket (the rocket is the camera subject) unless it is not moving. The testing I had done with similar code previously worked just fine.
(I’ve also tried to make the subject a part inside of the model and the model itself)

Camera subject code:

local active = false

script.Parent.MouseButton1Click:Connect(function()
	game:GetService("ReplicatedStorage").Control.launch:FireServer()
	task.wait(.3)
	local y = nil
	local x = workspace.PlayerBuilds:FindFirstChild(game.Players.LocalPlayer.Name.. "s Build")
	for i,v in pairs(x:GetDescendants()) do
		if v.Name == "Core" then
			v = y
		end
	end
	game:GetService("RunService").RenderStepped:Connect(function()
		print("banana")
		workspace.CurrentCamera.CameraSubject = x
	end)
end)

image

Your variable names kinda suck, but it looks like you set Y to where the camera subject is meant to be, then just, never use it, instead setting camera subject to X. And also instead of setting Y to anything, you set the core to nil, and used Y as basically just a shortener.
So, id assume your issue is as simple as that, set camera subject to Y instead of X.

local active = false

script.Parent.MouseButton1Click:Connect(function()
	game:GetService("ReplicatedStorage").Control.launch:FireServer()
	task.wait(.3)
	local x = workspace.PlayerBuilds:FindFirstChild(game.Players.LocalPlayer.Name.. "s Build")
	for i,v in pairs(x:GetDescendants()) do
		if v.Name == "Core" then
			workspace.CurrentCamera.CameraSubject = v
            break
		end
	end
end)

There may be other issues with the script, so it may still be broken.

1 Like

My bad, was using that just to check if setting it to a part was the issue and forgot to comment it afterwards. But as it turns out I just noticed that i mixed around v and y (which means you’re probably right because of the god awful variable names), after changing them it did work! Now I feel incredibly dumb as the last 2 days i’ve worked on this it was literally just switching variables. Thank you so much for helping me solve the issue and taking time out of your day to help!