Attempt to index nil with Character

Variables I have up towards the top of the code.

local Bin = game.ReplicatedStorage.BindableFunction
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local lp = game.Players:FindFirstChild(“Humanoid”)

local Spawned = false
game:GetService("Players").PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(Char)
		Spawned = true
		old = lp.Character.Torso["Right Shoulder"].C1
		old2 = lp.Character.Torso["Left Shoulder"].C1
	end)
end)

mouse = game.Players.LocalPlayer:GetMouse()
Camera = game.Workspace.Camera


game:GetService('RunService').RenderStepped:connect(function()
	if (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude < 1 and Spawned and lp.Character and lp.Character.Humanoid.Health > 0   then
		mouse.TargetFilter = nil
		lp.Character.Torso["Right Shoulder"].C1 = old * CFrame.Angles(0, 0, math.tan((mouse.Hit.p - mouse.Origin.p).unit.y)*-1)
		lp.Character.Torso["Left Shoulder"].C1 = old2 * CFrame.Angles(0, 0, math.tan((mouse.Hit.p - mouse.Origin.p).unit.y))
	elseif lp.Character and lp.Character.Humanoid.Health > 0 and Spawned and lp.Character then -- this is line 121
		lp.Character.Torso["Right Shoulder"].C1 = old
		lp.Character.Torso["Left Shoulder"].C1 = old2
	end
end)

You’re trying to check the PLAYER for a humanoid.
change this: local lp = game.Players:FindFirstChild(“Humanoid”)

to this = local lp = game.Players.LocalPlayer.Character:FindFirstChild(“Humanoid”)

Still the same issue unfortunately

What is line 121? could you give me that?

1 Like

elseif lp.Character and lp.Character.Humanoid.Health > 0 and Spawned and lp.Character then – this is line 121

Lp is a humanoid, you have to check the player for a character. try doing
elseif Player(variable) and lp.Health > 0 and Spawned and Player then

local Bin = game.ReplicatedStorage.BindableFunction
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local lp = Character:FindFirstChild(“Humanoid”)

local Spawned = false
game:GetService("Players").PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(Char)
		Spawned = true
		old = lp.Parent.Torso["Right Shoulder"].C1
		old2 = lp.Parent.Torso["Left Shoulder"].C1
	end)
end)

mouse = game.Players.LocalPlayer:GetMouse()
Camera = game.Workspace.Camera


game:GetService('RunService').RenderStepped:connect(function()
	if (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude < 1 and Spawned and lp.Parent and lp.Health > 0   then
		mouse.TargetFilter = nil
		lp.Parent.Torso["Right Shoulder"].C1 = old * CFrame.Angles(0, 0, math.tan((mouse.Hit.p - mouse.Origin.p).unit.y)*-1)
		lp.Parent.Torso["Left Shoulder"].C1 = old2 * CFrame.Angles(0, 0, math.tan((mouse.Hit.p - mouse.Origin.p).unit.y))
	elseif lp.Parent and lp.Health > 0 and Spawned and lp.Parent then -- this is line 121
		lp.Parent.Torso["Right Shoulder"].C1 = old
		lp.Parent.Torso["Left Shoulder"].C1 = old2
	end
end)

lp is the humanoid so you want to use lp.Parent.Torso to get the torso because lp.Character will always return nil (humanoid does not have a character property)

Thank you both for helping me understand and fix my error.