Attempt to index nil with AutoRotate

I’ve been making a gun system, but for some reason I get the error in the title.
Is AutoRotate deprecated?

You are indexing nil with AutoRotate, so whatever you used to access AutoRotate (i.e. index) is nil not AutoRotate.

-- ...
local Humanoid = Character:WaitForChild("Humanoid")

-- ...
-- Inside a function:
Humanoid.AutoRotate = true

How is the function being called? Where is this code running?

	local IsGun = Remotes.DetectGun:InvokeServer(Obj)
	if IsGun then
		GunSettings = Remotes.GetGunSettings:InvokeServer(Obj)
		Humanoid.AutoRotate = true
		Status.isEquipped = true
		tool = Obj
		Mouse.Icon = ""
		print("Equipped "..Obj.Name)

		currentAmmo = Remotes.GetAmmoCount:InvokeServer(Obj.Name)


Check Humanoid before using it. You obtain the Humanoid at the top of the script but if the player has died, chooses to reset, or is respawned, then Humanoid will be nil. Also if the player has died then Character will also be nil. You need to connect to CharacterAdded and CharacterRemoving so that you can reassign Character and Humanoid each time any of the two events above are called.

And always check variables before indexing them, i.e.

	if IsGun then
		GunSettings = Remotes.GetGunSettings:InvokeServer(Obj);
		if not GunSettings then
			-- what if this is nil too?
		if not Humanoid then
			Humanoid = Character:WaitForChild("Humanoid");
		if Humanoid then
			Humanoid.AutoRotate = true;