How do I fix error index nil with 'name' error?

My code keeps returning in the output " 04:03:11.032 Players.IsaiahCoolKidYo.PlayerScripts.FrameworkClient:80: attempt to index nil with ‘FakeCamera’ - Client - FrameworkClient:80".

It is a local script in StarterCharacterScripts:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild(“Humanoid”)

local userInputService = game:GetService(“UserInputService”)
local runService = game:GetService(“RunService”)

local camera = workspace.CurrentCamera

local aimCFrame = CFrame.new()

local mouse = player:GetMouse()

local isAiming = false
local isShooting = false
local isReloading = false
local isSprinting = false
local canShoot = true

local debounce = false

local currentSwayAmount = -.3
local swayAmount = -.3
local aimSwayAmount = .2
local swayCFrame = CFrame.new()
local lastCameraCFrame = CFrame.new()
local bobOffset = CFrame.new()

local fireAnimation = nil

local framework = {
inventory = {
“GLOCK17”;
“M4A1”;
“Knife”;
“Frag”;
};

module = nil;
viewModel = nil;
currentSlot = 1;
}

function loadSlot(item)
if isReloading == false then
local viewModelFolder = game.ReplicatedStorage.Viewmodels
local moduleFolder = game.ReplicatedStorage.Modules

  for i, v in pairs(camera:GetChildren()) do
  	if v:IsA("Model") then
  		v:Destroy()
  	end
  end

  if moduleFolder:FindFirstChild(item) then
  	framework.module = require(moduleFolder:FindFirstChild(item))

  	if viewModelFolder:FindFirstChild(item) then
  		framework.viewModel = viewModelFolder:FindFirstChild(item):Clone()
  		framework.viewModel.Parent = camera

  		if framework.viewModel and framework.module and character then
  			fireAnimation = Instance.new("Animation")
  			fireAnimation.Parent = framework.viewModel
  			fireAnimation.Name = "FireAnimation"
  			fireAnimation.AnimationId = framework.module.fireAnimation
  			fireAnimation = framework.viewModel.AnimationController.Animator:LoadAnimation(fireAnimation)

  			game.ReplicatedStorage.Events.LoadSlot:FireServer(framework.module.fireSound.SoundId, framework.module.fireSound.Volume)
  		end
  	end
  end

end
end

local oldCameraCFrame = CFrame.new()

function updateCameraShake()
local newCameraCFrame = framework.viewModel.FakeCamera.CFrame:ToObjectSpace(framework.viewModel.PrimaryPart.CFrame)
camera.CFrame = camera.CFrame * newCameraCFrame:ToObjectSpace(oldCameraCFrame)
oldCameraCFrame = newCameraCFrame
end

local hud = player.PlayerGui:WaitForChild(“Hud”)

runService.RenderStepped:Connect(function()
if humanoid then
local rotation = camera.CFrame:ToObjectSpace(lastCameraCFrame)
local x, y, z = rotation:ToOrientation()
swayCFrame = swayCFrame:Lerp(CFrame.Angles(math.sin(x) * currentSwayAmount, math.sin(y) * currentSwayAmount, 0), .1)
lastCameraCFrame = camera.CFrame

  if hud and humanoid then
  	if framework.viewModel and framework.module then
  		hud.GunName.Text = framework.inventory[framework.currentSlot]
  		hud.Ammo.Text = framework.module.ammo
  		hud.Ammo.MaxAmmo.Text = framework.module.maxAmmo
  	end
  end

  if framework.viewModel ~= nil and framework.module ~= nil then
  	if humanoid.MoveDirection.Magnitude > 0 then
  		if humanoid.WalkSpeed == 10 then
  			bobOffset = bobOffset:Lerp(CFrame.new(math.cos(tick() * 4) * .05, -humanoid.CameraOffset.y/3, 0) * CFrame.Angles(0, math.sin(tick() * -4) * -.05, math.cos(tick() * -4) * .05), .1)
  			isSprinting = false

  		elseif humanoid.WalkSpeed == 20 then
  			bobOffset = bobOffset:Lerp(CFrame.new(math.cos(tick() * 8) * .1, -humanoid.CameraOffset.y/3, 0) * CFrame.Angles(0, math.sin(tick() * -8) * -.1, math.cos(tick() * -8) * .1) * framework.module.sprintCFrame, .1)
  			isSprinting = true
  		end
  	end
  end

  for i, v in pairs(camera:GetChildren()) do
  	if v:IsA("Model") then
  		v:PivotTo(camera.CFrame * swayCFrame * aimCFrame * bobOffset)
  		updateCameraShake()
  	end
  end

  if framework.viewModel ~= nil then
  	if isAiming and framework.module.canAim and isSprinting == false then
  		local offset = framework.viewModel.AimPart.CFrame:ToObjectSpcae(framework.viewModel.PrimaryPart.CFrame)
  		aimCFrame = aimCFrame:Lerp(offset, framework.module.aimSmooth)
  		currentSwayAmount = aimSwayAmount

  	else
  		local offset = CFrame.new()
  		aimCFrame = aimCFrame:Lerp(offset, framework.module.aimSmooth)
  		currentSwayAmount = swayAmount
  	end
  end

end
end)

userInputService.MouseIconEnabled = false

userInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.One then
if framework.currentSlot ~= 1 and isReloading == false then
loadSlot(framework.inventory[1])
framework.currentSlot = 1
end
end

if input.KeyCode == Enum.KeyCode.Two and isReloading == false then
if framework.currentSlot ~= 2 then
loadSlot(framework.inventory[2])
framework.currentSlot = 2
end
end

if input.KeyCode == Enum.KeyCode.Three and isReloading == false then
if framework.currentSlot ~= 3 then
loadSlot(framework.inventory[3])
framework.currentSlot = 3
end
end

if input.KeyCode == Enum.KeyCode.Four and isReloading == false then
if framework.currentSlot ~= 4 then
loadSlot(framework.inventory[4])
framework.currentSlot = 4
end
end

if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = true
end

if input.UserInputType == Enum.UserInputType.MouseButton1 then
if character and framework.viewModel and framework.module and framework.module.ammo > 0 and debounce == false and isReloading ~= true and canShoot == true then
if framework.module.fireMode == “Semi” then
fireAnimation:Play()
framework.module.ammo -= 1

  		game.ReplicatedStorage.Events.Fire:FireServer()
  		
  		debounce = true
  		
  		wait(framework.module.debounce)
  		
  		debounce = false
  	end
  	
  	if framework.module.fireMode == "Full Auto" then
  		isShooting = true
  	end
  end

end

if input.KeyCode == Enum.KeyCode.R then
canShoot = false
isReloading = true

  wait(framework.module.reloadSpeed)
  
  canShoot = true
  isReloading = false
  framework.module.ammo = framework.module.maxAmmo

end
end)

userInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = false
end
end)

game.ReplicatedStorage.Events.PlayerAdded.OnClientEvent:Connect(function(plr, char)

player = game.Players.LocalPlayer
character = player.CharacterAdded:Wait()
humanoid = character:WaitForChild(“Humanoid”)

humanoid.Died:Connect(function()
player = nil
character = nil
humanoid = nil

  local aimCFrame = CFrame.new()

  local isAiming = false
  local isShooting = false
  local isReloading = false
  local isSprinting = false
  local canShoot = true

  local debounce = false

  local currentSwayAmount = -.3
  local swayAmount = -.3
  local aimSwayAmount = .2
  local swayCFrame = CFrame.new()
  local lastCameraCFrame = CFrame.new()
  local bobOffset = CFrame.new()

  local fireAnimation = nil

  if camera:FindFirstChildWhichIsA("Model") then
  	camera:FindFirstChildWhichIsA("Model"):Destroy()
  end

  local framework = {
  	inventory = {
  		"GLOCK17";
  		"M4A1";
  		"Knife";
  		"Frag";
  	};

  	module = nil;
  	viewModel = nil;
  	currentSlot = 1;
  }
  
  loadSlot(framework.inventory[1])

end)
end)

while wait() do
if isShooting and framework.module.ammo > 0 and isReloading ~= true and canShoot == true then
fireAnimation:Play()
framework.module.ammo -= 1

  game.ReplicatedStorage.Events.Fire:FireServer()
  
  debounce = true
  
  wait(framework.module.debounce)
  
  debounce = false
  
  mouse.Button1Up:Connect(function()
  	isShooting = false
  	
  end)
  
  wait(framework.module.fireRate)

end
end

game.ReplicatedStorage.Events.PlayerAdded.OnClientEvent:Connect(function(plr, char)

end)

Which line is erroring? Also, since it is in StarterCharacterScripts, you can just do local character = script.Parent

I dunno, maybe your viewModel on 80 line might be nil, the simplest solution would be just checking if it’s nil or not.

Attempt to index nil means you tried to check if X is a child of Y, but Y turns out to be nil. This results in an error, because nil is nil, and can’t ever have children.

Line 80 is erroring. I don’t know why it is happening. Everything seems right.