[HELP] Camera only focusing on Player and nothing else

You can write your topic however you want, but you need to answer these questions:
I want to achieve something like this a camera system similar to Super Smash Bros or a tekken style camera

https://gyazo.com/0c09a1d3c08d0931cf4be9da8db4c4b2

But this is the issue?

https://gyazo.com/07b46953a11ae66731a3f05a2a24e69e

I tried look for solutions on the Developer Hub and devforms but I had no luck

P.S. the script is not mines its from @fipsii123

--//Services\\--
local RunService = game:GetService("RunService")
local TS = game:GetService("TweenService")

--//Variables\\--
local player = game.Players.LocalPlayer
local players = game:GetService("Players")
local char = player.Character or player.CharacterAdded:Wait() 
local HRP = char:WaitForChild("HumanoidRootPart")

local positionvar = Vector3.new(0,0,0)
local xvalues = {}
local zoom = 55
local number 

local camera = workspace.CurrentCamera
camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 40


--//Functions\\--
local function UpdateCam()
	--Get players									
	local playernum = game.Players:GetPlayers()
	number = #playernum

	-- Insert position in the table
	for _, playername in pairs(players:GetPlayers()) do
		if positionvar.X < 330 then
			positionvar = positionvar + playername.Character.HumanoidRootPart.Position
			table.insert(xvalues, playername.Character.HumanoidRootPart.Position.X)

			-- If player is out of bounds ignore him by removing the position from the table and subtracting the total amount of players by 1
		else
			table.remove(xvalues, playername.Character.HumanoidRootPart.Position.X)
			if number > 1 then
				number = number - 1
			end
		end
	end

	-- Sort Table
	table.sort(xvalues,
		function(a,b)
			return a > b 
		end)	

	-- calculate zoom and get camera position
	if xvalues[number] ~= nil then
		zoom = math.abs(xvalues[number] - xvalues[1]) * 1.25
		-- calculate the camera position by taking the mean value of all the player positions
		positionvar = positionvar/number
	end

	-- tween camera to the desired postition
	if zoom < 55 then
		local Tween = TS:Create(camera, TweenInfo.new(0.5), {CFrame = CFrame.new(positionvar) * CFrame.new(1,1,55)}):Play()
	elseif zoom < 200 then
		local Tween = TS:Create(camera, TweenInfo.new(0.5), {CFrame = CFrame.new(positionvar) * CFrame.new(1,1,zoom)}):Play()
	end	

	-- reset
	positionvar = Vector3.new(0,0,0)
	xvalues = {}
end

--//Core\\--
-- Update the camera
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, UpdateCam)
1 Like

I don’t quite understand what the problem is, can you elaborate further?

Im trying to make a camera system similar to Super Smash Bros or a tekken where it adjusts the camera to where both players are in the camera’s frame.

So, you want to put the camera in-between both characters, and zoom out until you can see both?

1 Like

yes, this is what is want but the script doesn’t work

In the line if positionvar.X < 330, to determine if they are not in the arena, shouldn’t there be one like and positionvar.X > -330

Also, shouldn’t this code have an else statement for any zoom over 200. And another question I have for this code snippet is, why are you setting a variable tween to a tween being played, and the variable not even being accessed?

if zoom < 55 then
		TS:Create(camera, TweenInfo.new(0.5), {CFrame = CFrame.new(positionvar) * CFrame.new(1,1,55)}):Play()
	elseif zoom < 200 then
		TS:Create(camera, TweenInfo.new(0.5), {CFrame = CFrame.new(positionvar) * CFrame.new(1,1,zoom)}):Play()
	else 
		TS:Create(camera, TweenInfo.new(0.5), {CFrame = CFrame.new(positionvar) * CFrame.new(1,1,200)}):Play()
	end	
1 Like