Humanoid is not a valid member of Camera "Workspace.Camera"

What is the issue here? I’ve been stuck on it for hours and can’t seem to get it to work

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local ragdoll = require(game.ServerScriptService.RagdollModule)
local grip = game.ReplicatedStorage.Remotes.Grip
local carry = game.ReplicatedStorage.Remotes.Carry

carry.OnServerEvent:Connect(function(player, Value)
	for i,v in pairs(workspace:GetDescendants()) do
		if game.Players:FindFirstChild(v.Name) and v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") and v.Values.Status:FindFirstChild("KnockedTimer").Value > 0 and v.Values.Status:FindFirstChild("KnockedTimer").Value and v.Values.Status:FindFirstChild("Carried").Value == false and (character.Torso.Position - v.Torso.Position).magnitude <= 5 then
			local vplayer = game.Players:GetPlayerFromCharacter(v)
			local vhumanoid = v.Humanoid
			if Value == "PickUp" then
				print(character.Torso.Position - v.Torso.Position)
				local weld = Instance.new("Weld", hrp )
				local anim3 = v:FindFirstChild("Animations").Carried
				local attack3 = vhumanoid:LoadAnimation(anim3)
				attack3:Play()
				local anim4 = character:FindFirstChild("Animations").Carrying
				local attack4 = humanoid:LoadAnimation(anim4)
				attack4:Play()
				ragdoll.Stop(vplayer)
				local limbs = v:GetDescendants();
				for i = 1, #limbs do 
					if limbs[i]:IsA'BasePart' then
						limbs[i].Massless = true;
					end	
				end	
				weld.Name = "CarryWeld"
				weld.Part0 = hrp
				weld.Part1 = v.HumanoidRootPart
				weld.C0 = CFrame.new(1.4,1.6,0)*CFrame.Angles(0,math.pi,0)
			end
		elseif Value == "Drop" then
			for i,v in pairs(hrp:GetChildren()) do
				if v.Name == "CarryWeld" then
					v:Destroy()
				end
			end
		end
	end
end)```

![image|594x69](upload://zYlSW16Jg07dDBoZ1ED8KY6HOrC.png)

Oops, here’s the error

image

Is this the right script? Your error says it’s in line 40. Your line 40 is just an end, which can’t be causing the error

Wouldn’t it be much faster to use game.Players:GetPlayers()?

Literally, Its just this:

for index, player in ipairs(game.Players:GetPlayers()) do
    print(player) -- the Table gives you all the Players, no need to iterate through everything to find a Player

end)

1 Like