Why is HumanoidRootPart nil

I’m trying to find a character to make it a cframe to go to the look vector, but it says humanoid root part is nil.
Script:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local function Move(x,y,z)
			for i=1,10 do
				script.Parent.CFrame = script.Parent.CFrame + Vector3.new(x,y,z)
				wait(0.1)
			end
		end

		script.Parent.Touched:Connect(function()
			if Character.HumanoidRootPart ~= nil then
				script.Parent.Position = Character.HumanoidRootPart.CFrame.LookVector * 5
				Move(1,0.25,0)
				Move(1,-0.25,0)
			end
		end)
	end)
end)

Output:
Humanoid is not a valid member of Workspace “Workspace”
Thanks for reading.

The error that you gave does not have anything to do with the script that you provided. Can you look into where the error is pointing to and provide the script that it is relating to?

1 Like

Please be more clear, I don’t see a “Humanoid” is used according to the error, did you mean HumanoidRootPart?

1 Like

I’m so sorry! It happened to a different script which I can fix. Sorry for not checking that was irresponsible of me.